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

sorting #25

Open
lue-bird opened this issue May 29, 2021 · 0 comments
Open

sorting #25

lue-bird opened this issue May 29, 2021 · 0 comments

Comments

@lue-bird
Copy link
Collaborator

lue-bird commented May 29, 2021

I miss sorting operations like sort, sortBy & sortWith in List the most when working with arrays.
I think these would be worth adding to elm/core's Array module. Until anything gets decided, array-extra could just copy Lists sorting API:

sortWith : (a -> a -> Order) -> Array a -> Array a
sortWith elementOrder array =
    array
        |> Array.toList
        |> List.sortWith elementOrder
        |> Array.fromList

-- same with sort & sortBy

An example use-case is finding an Arrays 5 biggest numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant