I've wanted such a function a few times because passing in the alternated 
function is not always clear.  Instead of `&>=/2` I'd rather do things like 
`&not(&1<&2)` as it makes it unambiguous while reading, and a prepending a 
`reverse_` to the sorts is even better still.  I'm +1 on this.

On Thursday, October 17, 2019 at 2:39:42 PM UTC-6, José Valim wrote:
>
> I would like to propose a new small function to Enum, called 
> Enum.reverse_sort, that returns sort in the reverse (descending order).
>
> While reversing sorting today is easy to achieve with:
>
> Enum.sort(collection, &>=/2)
>
> I always have a second guess on what the second argument really is. I 
> believe reverse_sort is much clearer in intent:
>
> Enum.reverse_sort(collection)
>
> This is clearer with sort_by too. instead of:
>
> Enum.sort_by(users, & &1.name, &>=/2)
>
> I can write:
>
> Enum.reverse_sort_by(users, & &1.name)
>
> The implementation itself is straight-forward.
>
> What I would like to know is:
>
> 1. Is this a good addition?
> 2. Is the name reasonable? Any other takers?
>
> *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 elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/6384264f-9b2f-4c5d-be5e-54f56d4f79b5%40googlegroups.com.

Reply via email to