Also, your counting sort function both mutates and returns the original array whilst your bucket sort array returns a new array, leaving the original untouched (better). This code is somewhat confused - better to stick with either mutating variables or not, don't mix the two.
Wouldn't this be simpler?
Better still, a version that doesn't mutate the original array:
Also, your counting sort function both mutates and returns the original array whilst your bucket sort array returns a new array, leaving the original untouched (better). This code is somewhat confused - better to stick with either mutating variables or not, don't mix the two.
These are great suggestions! Thanks for taking the time to reply. Time to make some edits :)