-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behavior using orderBy #361
Comments
Thanks! We will check this. |
Actually, lodash also have same this issue. But we have to fix this issue for expected behavior. This problem can be fixed by handling type coercion. I'll fix this issue today. |
This actually needs a little bit of more discussion, reopening the issue. |
I guess in this case, the ideal way of using orderBy(data, x => x.value.toString(), ["asc"]) This would ensure that all numbers and strings are converted into string before comparison. |
We have additional ways that we convert into string just using But I think custom key function is simpler than others. |
As you mentioned, I guess we might try with custom key generating functions. It would be much simple. |
Something wrong if the last element has another type
Using
orderBy(data, ["value"], ["asc"])
But if we change a bit data, its OK:
Example https://codesandbox.io/p/sandbox/es-toolkit-orderby-22zkzm
The text was updated successfully, but these errors were encountered: