elm-community / elm-community/array-extra

sorting

Open
#25 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Elm
Stars
10
Forks
9
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/elm/core/issues/1112). Until anything gets decided, `array-extra` could just copy `List`s sorting API:
```elm
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 `Array`s 5 biggest numbers.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.