mediumSorting1 bug
Bubble Sort Gives Up Early
The leaderboard is only "kind of" sorted — the top score is right, the rest are not.
bubbleSort(arr) sorts the array ascending in place (optimised bubble sort) and returns it.
Fix the code so every test passes. Keep the function name bubbleSort.
Test cases
- bubbleSort([5,3,4,1,2]) → [1,2,3,4,5]
- bubbleSort([2,1]) → [1,2]
- bubbleSort([3,1,2]) → [1,2,3]
- bubbleSort([1,2,3]) → [1,2,3]
Hints
each hint costs XPStuck? Hints go from a nudge to the exact fix.