sorting
lue-bird opened this issue · comments
lue commented
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 List
s 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 Array
s 5 biggest numbers.