DEV Community

Discussion on: Are one-liners always the best solutions?

Collapse
 
slnsrn profile image
Selin Serin

sorry, i forgot to mention.
You need to write the sort function explicitly. Otherwise sorts as a string and 4 > 1 :)

   arr.sort((a, b) => a - b)
Enter fullscreen mode Exit fullscreen mode