Sort Values
Problem statement
Given an integer array values, return a new array containing the same values in nondecreasing order. Keep every occurrence of a repeated value. Leave the input array unchanged.
Function
sortValues(values: int[]) → int[]Examples
Example 1
values = [3,1,2,1]return = [1,1,2,3]Both occurrences of 1 remain. Each output value is at least the previous value.
Example 2
values = []return = []An empty array has no values to reorder.
Example 3
values = [-4,0,-2]return = [-4,-2,0]Negative values come before 0, ordered by their numeric value.
Constraints
0 <= values.length <= 10000.-2147483648 <= values[i] <= 2147483647.