aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-278/steven-wilson/python/ch-1.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/challenge-278/steven-wilson/python/ch-1.py b/challenge-278/steven-wilson/python/ch-1.py
index 8e113ff425..18b5904a2a 100644
--- a/challenge-278/steven-wilson/python/ch-1.py
+++ b/challenge-278/steven-wilson/python/ch-1.py
@@ -16,8 +16,9 @@ def sort_string(string):
'The Weekly Challenge'
"""
p = re.compile('^(\w+)(\d+)$')
- words_sorted = sorted((p.search(word).groups() for word in string.split(" ")), key=itemgetter(1))
- return " ".join(word[0] for word in words_sorted)
+ words_numbers = (p.search(word).groups() for word in string.split(" "))
+ words_numbers_sorted = sorted(((w[0], int(w[1])) for w in words_numbers), key=itemgetter(1))
+ return " ".join(word[0] for word in words_numbers_sorted)
if __name__ == "__main__":