Skip to content
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

Haskell inspired sortWith #97

Merged
merged 1 commit into from Mar 26, 2017
Merged

Haskell inspired sortWith #97

merged 1 commit into from Mar 26, 2017

Conversation

negator
Copy link
Contributor

@negator negator commented Mar 21, 2017

Support for the GHC Ext sortWith function, which accepts a projection function.

http://hackage.haskell.org/package/base-4.9.1.0/docs/GHC-Exts.html#v:sortWith

-- | Sort the elements of an array in increasing order, where elements are
-- | sorted based on a projection
sortWith :: forall a b. Ord b => (a -> b) -> Array a -> Array a
sortWith f xs = sortBy comp' xs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use sortWith f = sortBy (comparing f)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent 👍

@garyb garyb merged commit 43d3690 into purescript:master Mar 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants