Comment on I'll just sort it myself

<- View Parent
KiofKi@feddit.de ⁨1⁩ ⁨year⁩ ago

“By default, the sort() function sorts values as strings.

This works well for strings (“Apple” comes before “Banana”).

However, if numbers are sorted as strings, “25” is bigger than “100”, because “2” is bigger than “1”.

Because of this, the sort() method will produce incorrect result when sorting numbers.”

www.w3schools.com/js/js_array_sort.asp

source
Sort:hotnewtop