A proposal for asc/desc has been sent:
https://github.com/elixir-lang/elixir/pull/9432


*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D


On Sun, Oct 20, 2019 at 8:52 AM José Valim <[email protected]>
wrote:

> The other option is to make reverse sort not stable by default, but that
> doesn’t sound like a good idea.
>
> Maybe other option I can think of is to allow the sorter function to be:
>
>     fun/2 | asc | desc | module | {:asc, module} | {:desc, module}
>
> This way we also solve the issue in that they require slightly different
> comparisons to solve reverse sorting.
>
> On Sun, Oct 20, 2019 at 08:06 Wiebe-Marten Wijnja <[email protected]> wrote:
>
>> Something that came to mind early this morning, is that in the way it is
>> currently defined, the following two things are *not* equal:
>>
>> collection
>> |> Enum.sort(&some_fun/2)
>> |> Enum.reverse
>>
>> collection
>> |> Enum.reverse_sort(&some_fun/2)
>>
>> The difference arises because of sorting stability: Assuming a stable
>> comparison function, `Enum.sort` is stable. This means that in the first
>> example, elements that are equal end up in the reverse order from their
>> original order.
>>
>> Because this difference in behaviour might be surprising, maybe we should
>> indeed find a different name for `Enum.reverse_sort`.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "elixir-lang-core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/elixir-lang-core/bb66639f-6feb-4eef-8db9-35a8f65e471f%40googlegroups.com
>> <https://groups.google.com/d/msgid/elixir-lang-core/bb66639f-6feb-4eef-8db9-35a8f65e471f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
>
>
> *José Valim*
> www.plataformatec.com.br
> Skype: jv.ptec
> Founder and Director of R&D
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KU0%3DD9kOz-C1RoEinQD3i770ySy0g-5-OdfDVp76jxeQ%40mail.gmail.com.

Reply via email to