Skip to content

sorting #25

@lue-bird

Description

@lue-bird

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions