--- id: 6a0dcd03ee4e68698080ef6d title: "Challenge 309: Number Sort" challengeType: 29 dashedName: challenge-309 --- # --description-- Given a string of numbers separated by commas, return an array of the numbers sorted from smallest to largest. # --hints-- `sort_numbers("3,1,2")` should return `[1, 2, 3]`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(sort_numbers("3,1,2"), [1, 2, 3])`) }}) ``` `sort_numbers("5,3,8,1,9,2")` should return `[1, 2, 3, 5, 8, 9]`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(sort_numbers("5,3,8,1,9,2"), [1, 2, 3, 5, 8, 9])`) }}) ``` `sort_numbers("12,61,49,80,19,50,77,38")` should return `[12, 19, 38, 49, 50, 61, 77, 80]`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(sort_numbers("12,61,49,80,19,50,77,38"), [12, 19, 38, 49, 50, 61, 77, 80])`) }}) ``` `sort_numbers("0,6,-19,44,-2,7,0")` should return `[-19, -2, 0, 0, 6, 7, 44]`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(sort_numbers("0,6,-19,44,-2,7,0"), [-19, -2, 0, 0, 6, 7, 44])`) }}) ``` # --seed-- ## --seed-contents-- ```py def sort_numbers(s): return s ``` # --solutions-- ```py def sort_numbers(s): return sorted(int(x) for x in s.split(",")) ```