Bubble Sort
Sorting is built in, but implementing one teaches how they work. Bubble sort repeatedly walks the list, swapping adjacent out-of-order pairs until none remain. Work on a copy so you don't mutate the input.
Your task
Write bubbleSort(arr) that returns a new array sorted ascending.
β‘ 45 XP
solution.jsRuns in your browser
Loading editorβ¦
Tests3 to pass
[3,1,2] β [1,2,3]
empty
reversed
Run your code to check these.