algorithms-exercises icon indicating copy to clipboard operation
algorithms-exercises copied to clipboard

Missing compare function in test

Open patgarcia opened this issue 4 years ago • 0 comments

According to MDN docs on Array.prototype.sort

The default sort order is ascending, built upon converting the elements into strings

[100,2].sort()
// [100, 2]

So we would need the compare function to sort numbers properly

[100,2].sort((a,b) => a - b)
// [2, 100]

patgarcia avatar Jul 24 '21 16:07 patgarcia