Skip to content

Enum.min_max should take a sorting function #14684

@flexagoon

Description

@flexagoon

Elixir and Erlang/OTP versions

Erlang/OTP 28 [erts-16.0.2] [source] [64-bit] [smp:20:20] [ds:20:20:10] [async-threads:1] [jit:ns]

Elixir 1.18.4 (compiled with Erlang/OTP 27)

Operating system

Linux

Current behavior

All Enum min/max functions (i.e. Enum.min, Enum.max and Enum.min_max_by) have an overload that takes a sorting function, allowing to sort structs with a compare method, like dates. However, Enum.min_max doesn't have an overload like that and doesn't allow a custom sort function.

Expected behavior

{min_date, max_date} = Enum.min_max(dates, Date)

This should be possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions