Fix a demo.
This commit is contained in:
parent
8c3fb39440
commit
f1ca811abb
|
@ -24,7 +24,6 @@
|
||||||
# - Handles blank input lines correctly
|
# - Handles blank input lines correctly
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import string
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -32,18 +31,13 @@ def main():
|
||||||
def makekey(item, prog=prog):
|
def makekey(item, prog=prog):
|
||||||
match = prog.match(item)
|
match = prog.match(item)
|
||||||
if match:
|
if match:
|
||||||
var, num = match.group(1, 2)
|
var, num = match.groups()
|
||||||
return string.atoi(num), var
|
return int(num), var
|
||||||
else:
|
else:
|
||||||
# Bad input -- pretend it's a var with value 0
|
# Bad input -- pretend it's a var with value 0
|
||||||
return 0, item
|
return 0, item
|
||||||
while 1:
|
for line in sys.stdin:
|
||||||
line = sys.stdin.readline()
|
items = sorted(makekey(item) for item in line.split())
|
||||||
if not line:
|
|
||||||
break
|
|
||||||
items = line.split()
|
|
||||||
items = map(makekey, items)
|
|
||||||
items.sort()
|
|
||||||
for num, var in items:
|
for num, var in items:
|
||||||
print "%s=%s" % (var, num),
|
print "%s=%s" % (var, num),
|
||||||
print
|
print
|
||||||
|
|
Loading…
Reference in New Issue