Sort the Array
Easy · rating 1050 · sorting, arrays
The first line contains n. The second line contains n space-separated integers. Print them sorted in non-decreasing order, space-separated on one line.
Constraints: 1 ≤ n ≤ 105
Editorial
Sort the Array asks you to output the integers in non-decreasing order — a direct use of your language's built-in sort.
Note
Library sorts (Timsort, introsort) are O(n log n) and heavily optimized; hand-rolling a sort is rarely worthwhile outside of learning the algorithms themselves.
nums.sort()
print(*nums)Complexity
Time: O(n log n). Space: O(n) or O(1) depending on the sort.