File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323# - Outputs the sorted fields with exactly one space between them
2424# - Handles blank input lines correctly
2525
26- import regex
26+ import re
2727import string
2828import sys
2929
3030def main ():
31- prog = regex .compile ('^\ (.*\)=\ ([-+]?[0-9]+\ )' )
31+ prog = re .compile ('^(.*)= ([-+]?[0-9]+)' )
3232 def makekey (item , prog = prog ):
33- if prog .match (item ) >= 0 :
34- var , num = prog .group (1 , 2 )
33+ match = prog .match (item )
34+ if match :
35+ var , num = match .group (1 , 2 )
3536 return string .atoi (num ), var
3637 else :
3738 # Bad input -- pretend it's a var with value 0
@@ -40,7 +41,7 @@ def makekey(item, prog=prog):
4041 line = sys .stdin .readline ()
4142 if not line :
4243 break
43- items = string .split (line )
44+ items = line .split ()
4445 items = map (makekey , items )
4546 items .sort ()
4647 for num , var in items :
You can’t perform that action at this time.
0 commit comments