fast-sort icon indicating copy to clipboard operation
fast-sort copied to clipboard

Fix sorting of array with multiple types

Open snovakovic opened this issue 2 years ago • 2 comments

fixes https://github.com/snovakovic/fast-sort/issues/62

Running of benchmark and there is no noticeable effect on performance

image

snovakovic avatar Aug 24 '22 16:08 snovakovic

There is still some know issues with this update as e.g

sort([1, 3, 2, '1a', 'a', '2', '5', 6]).asc() // === [1,2,"2",3,"1a","5",6,"a"]

But currently trying to find balance between know issue and performance... It's easy to fix above but that require more check which have negative performance impact on every sort just for some edge cases. (&& we can always use naturalSort or any custom sort)

snovakovic avatar Aug 24 '22 16:08 snovakovic

@snovakovic how about providing a separate sort function that can be imported just for the case of arrays with multiple types.

I agree we shouldn't cause any degredation in the existing performance.

You could call it import { sortMultiTypeArray } from 'fast-sort' or something

and tree-shaking will make it so no one will have negative impact.

mesqueeb avatar Sep 15 '22 04:09 mesqueeb

@mesqueeb on second look manage to solve above issue without performance penalties so there is no need for separate function

snovakovic avatar Apr 15 '23 18:04 snovakovic