๐Debugging Missionยทintermediateยทโฑ๏ธ 20โ30mยทโญ 150 XP
M-065Fix the Broken Sort
Description
The array sorting function at Nebula Corp is producing wrong results for certain inputs. Engineers have reported that numeric arrays come back in the wrong order. Dig into the code, find the bug, and fix it.
Symptoms
wrong-outputNumbers are sorted lexicographically instead of numerically
wrong-outputsortArray([10, 2, 1]) returns [1, 10, 2] instead of [1, 2, 10]
Expected Behavior (2)
Sorts positive integers
Basic numeric sort
Input:sortArray([10, 2, 1])
Expected:CONTAINS:1,2,10
Sorts negative numbers
Handles negatives
Input:sortArray([-3, 1, -1])
Expected:CONTAINS:-3,-1,1
Related Lessons
Click Run / Check to validate your solution