When I found out javascript's sort() function takes an optional compare function I used that in sort-by, but now I realize that the expected behavior was lost and now I'm not sure how to restore it while keeping the ability to pass a key function to sort-by.
The default behavior works by converting the elements to strings and using each of their unicode values. This is what allows this to work:
I think I need to better understand how the compare functions work to know how to solve it, but one thought is to add special cases for if the items are strings.
When I found out javascript's
sort()
function takes an optional compare function I used that insort-by
, but now I realize that the expected behavior was lost and now I'm not sure how to restore it while keeping the ability to pass a key function to sort-by.The default behavior works by converting the elements to strings and using each of their unicode values. This is what allows this to work:
I think I need to better understand how the compare functions work to know how to solve it, but one thought is to add special cases for if the items are strings.