You are given a list of shipment values and need to produce the same list in ascending order.
This is not a filtering problem. You do not remove repeated numbers, and you do not treat negative values specially. Every original number must appear in the returned list.
For example, [4,-1,4,3] should become [-1,3,4,4]. If the input is [7,2,5,2], the answer is [2,2,5,7], which keeps both copies of 2.
The result should be the same shipment data, just arranged from the smallest value to the largest.
Example Input & Output
Negative and positive labels appear in ascending order, with repeated values preserved.
An empty shipment produces an empty manifest.
The returned manifest lists the labels from smallest to largest while keeping both copies of 2.
Algorithm Flow

Solution Approach
The direct solution is to sort the array in increasing order.
If your language has a built-in numeric sort, that is enough here. Otherwise, any standard sorting algorithm like merge sort, quicksort, or heapsort will work.
There are no special edge cases beyond keeping every value. Empty input stays empty, and repeated values naturally stay repeated after sorting.
The overall time complexity is typically O(n log n).
Best Answers
import java.util.*;
class Solution {
public int[] ascending_manifest(Object input) {
int[] nums = (int[]) input;
int[] res = nums.clone();
Arrays.sort(res);
return res;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
