Sort undefined according to the comparison function #195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request implements Data.Array.sortBy and Data.Array.ST.sortBy with the merge sort proposed in #155, so that
undefined
is sorted according to the comparison function and not to the end of the array (this also applies to Data.Array.NonEmpty.sortBy because it is implemented with Data.Array.sortBy). The only liberty I took with the implementation was to get rid of the uncurried functions since we’re not using any elsewhere in this library.Do we also want
unsafeSort :: forall a. Ord a => Array a -> Array a
,unsafeSortBy :: forall a. (a -> a -> Ordering) -> Array a -> Array a
andunsafeSortWith :: forall a b. Ord b => (a -> b) -> Array a -> Array a
functions, implemented with the native Array.prototype.sort method?Close #155.