minus-squareKiofKi@feddit.detoProgrammer Humor@programming.dev•I'll just sort it myselflinkfedilinkarrow-up15·10 months 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." https://www.w3schools.com/js/js_array_sort.asp linkfedilink
minus-squareKiofKi@feddit.detoProgrammer Humor@programming.dev•PlEaSe CeNtEr ThAt DiVlinkfedilinkarrow-up7·11 months agoAnd grid if you’re feeling fancy linkfedilink
minus-squareKiofKi@feddit.detoAsklemmy@lemmy.ml•What book had the greatest impact on your life, and which part of it is the most memorable for you?linkfedilinkEnglisharrow-up4·1 year agoIt was Guards!Guards! for me. GNU linkfedilink
"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."
https://www.w3schools.com/js/js_array_sort.asp