You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for creating es-toolkit, we are migrating today and love it. Really appreciate all your hard work!
It would be nice if sortBy/orderBy supported an array of strings. This is pretty common IMO and worked with lodash. Ordering by lower case, or by string length, or some kind of category lookup, or natural sort, or first word in a sentence, etc. Thanks again!
Thank you for the suggestion, and I'm glad to hear that you're enjoying es-toolkit!
After some consideration, though, I believe that for arrays of strings, using the native sort directly is much more natural and better ergonomics:
arr.sort((x,y)=>x.localeCompare(y));// By lower casearr.sort((x,y)=>x.toLowerCase().localeCompare(y.toLowerCase()));// By string lengtharr.sort((x,y)=>x.length-y.length);
sortBy and orderBy are designed for sorting arrays of objects by their properties, and extending them to primitives would add complexity to the API without a clear benefit over what modern JavaScript already provides.
So I'll close this issue. Thanks again for your interest in es-toolkit!
Activity
raon0211 commentedon Dec 7, 2024
Hello :) Let us look into this.
gurgeous commentedon Dec 7, 2024
Great, let me know if I can help! I think
compat/sortByhandles it appropriatelyraon0211 commentedon Jul 5, 2026
Thank you for the suggestion, and I'm glad to hear that you're enjoying es-toolkit!
After some consideration, though, I believe that for arrays of strings, using the native sort directly is much more natural and better ergonomics:
sortByandorderByare designed for sorting arrays of objects by their properties, and extending them to primitives would add complexity to the API without a clear benefit over what modern JavaScript already provides.So I'll close this issue. Thanks again for your interest in es-toolkit!