-
-
Notifications
You must be signed in to change notification settings - Fork 657
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
Don't depend on unordered object #393
Conversation
Before, passing `range` as `{min: 1, max: 5, 25%: 2, 50%: 3}` and `{min: 1, 25%: 2, 50%: 3, max: 5}` would mean different results. Because objects are not guaranteed to return keys in same order, 2 resulting number arrays need to be sorted.
There are also Also please let me know if you want me to add tests for this. |
This is also similar to #323 |
The other arrays would need sorting too, as they are referenced by the same indexes as the range. Im fairly sure the current tests will guarantee the normal behavior, but tests demonstrating the ability to provide unsorted arrays would be nice. I'm working to get some other fixes merged, so this could ship before the new year. |
How do I approach sorting the other two, then? They contain mixed type values, numeric sort won't do as easily. What are they for? |
|
Turn range into array, sort it by value and use then. This makes sure that all 4 arrays are naturally ordered the same way.
It passes tests |
This is in the newest release: 7.0.10. Thanks a lot for your contributions! |
Awesome! And thanks a lot for your prompt replies :)
|
Before, passing
range
as{min: 1, max: 5, 25%: 2, 50%: 3}
and{min: 1, 25%: 2, 50%: 3, max: 5}
would mean different results.Because objects are not guaranteed to return keys in same order, 2 resulting number arrays need to be sorted.