You are given an integer array nums.
Rearrange elements of nums in non-decreasing order of their absolute value.
Return any rearranged array that satisfies this condition.
Note: The absolute value of an integer x is defined as:
x if x >= 0-x if x < 0Example 1:
Input: nums = [3,-1,-4,1,5]
Output: [-1,1,3,-4,5]
Explanation:
nums are 3, 1, 4, 1, 5 respectively.[-1, 1, 3, -4, 5]. Another possible rearrangement is [1, -1, 3, -4, 5].Example 2:
Input: nums = [-100,100]
Output: [-100,100]
Explanation:
nums are 100, 100 respectively.[-100, 100]. Another possible rearrangement is [100, -100].Constraints:
1 <= nums.length <= 100-100 <= nums[i] <= 100Loading editor...
[3,-1,-4,1,5]