At Spotify, event scores arrive in arbitrary order and must be sorted efficiently before downstream processing. Given an array of integers nums, return a new array containing the same values sorted in ascending order.
You must solve this efficiently for large inputs. A quadratic-time approach such as comparing every pair is not acceptable for the largest cases.
numssort() or sorted()Example 1
nums = [5, 2, 3, 1][1, 2, 3, 5][1, 2, 3, 5].Example 2
nums = [5, 1, 1, 2, 0, 0][0, 0, 1, 1, 2, 5]1 <= len(nums) <= 10^5-10^9 <= nums[i] <= 10^9O(n log n) time or better