Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

66 lines
1.3 KiB
Markdown

---
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(","))
```