Sort an Absolute-Value-Sorted Array
Problem statement
nums is sorted by nondecreasing absolute value. Return its values in ordinary nondecreasing numeric order in linear time.
Function
sortAbsoluteArray(nums: int[]) → int[]Examples
Example 1
nums = [0,-1,2,-4,5,6,-10,-13,-22]return = [-22,-13,-10,-4,-1,0,2,5,6]Negative values reverse their absolute-value order before merging with nonnegative values.
Constraints
0 <= nums.length <= 10^5.- Absolute values are nondecreasing.