Sort Using Built-in Sort
EasyP3Coding
Return the array nums sorted in ascending numeric order, using your language's built-in sort.
The point of this problem is to know the built-in correctly: in JavaScript, Array.prototype.sort with no comparator sorts values as strings, so [10, 9, 1] becomes [1, 10, 9].
Example 1
- Input
- nums = [10,9,1]
- Output
- [1,9,10]
Example 2
- Input
- nums = [-1,3,-10,2]
- Output
- [-10,-1,2,3]
Example 3
- Input
- nums = []
- Output
- []
Constraints
- 0 <= nums.length <= 10^5
- -10^9 <= nums[i] <= 10^9
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 9. ⌘Enter runs, ⌘⇧Enter submits.