In Atrium Tour Sorter, you are given an array of badge numbers and need to return those numbers sorted from smallest to largest.
The values themselves should not change. You are only reordering them. If a number appears more than once, every copy should still be present in the result. Negative numbers and zero are valid too, so they should be placed using normal numeric order just like positive values.
For example, nums = [18,4,9,4] should become [4,4,9,18]. Both copies of 4 stay in the array; they just move into their sorted positions. If nums = [0,-3,7], the answer is [-3,0,7] because -3 is the smallest value.
An empty array returns an empty array, and a single-element array returns that same one value. So the task is simply to sort the input numerically in ascending order and return the ordered list.
Example Input & Output
Duplicate family badges remain while the list climbs from lowest to highest.
An empty signup produces an empty roster for the guides.
Negative placeholders and positive badges appear together in ascending order.
Algorithm Flow

Solution Approach
The most direct solution is to perform an ascending numeric sort on the array and return the sorted result. Since the entire problem is just about arranging badge numbers from smallest to largest, a normal sort is exactly the right tool.
The main thing to watch is that the sort must be numeric. In some languages, the default sort treats values like strings unless you provide a comparator. That can cause mistakes such as placing 18 before 4 because the first character 1 comes before 4. So even though the problem is easy, it still has one important technical detail: compare the numbers by numeric value, not by their text form.
In JavaScript, a clean version looks like this:
This creates a copy first, which is nice if you want to leave the original input untouched. Then the comparator a - b enforces ascending order. If a is smaller than b, the comparator returns a negative value, so a is placed earlier in the sorted array.
This handles duplicates naturally. If the input contains two 4 values, both remain in the result because sorting reorders elements but does not delete them. Negative numbers also work without any extra logic. A value like -5 simply compares as smaller than 0 or 10, so it moves toward the front.
Edge cases stay simple too. An empty array has nothing to sort, so the returned array is still empty. A one-element array is already sorted. Arrays containing repeated or mixed positive and negative values are handled by the same comparator with no special branches.
The time complexity is O(n log n), which is the normal cost of comparison sorting. Extra space depends on whether you sort in place or create a copy first. The version above uses O(n) additional space for the copied array.
So the full strategy is: take the badge number list, apply an ascending numeric sort with a proper comparator, and return the sorted array with every value still included.
Best Answers
import java.util.*;
class Solution {
public int[] sort_atrium_badges(int[] nums) {
int[] sortedArr = nums.clone();
Arrays.sort(sortedArr);
return sortedArr;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
