Re: Sort on linkedlists with double values (inside main list)

Paul King <[email protected]>
Newsgroups gmane.comp.lang.groovy.user
Message-ID <CAMbkE7StLLhPuajLPQmYq2uWqbto4MTqR=3OBQ2QtxUfEC5RVw@mail.gmail.com>
I am not 100% sure what you are after. If you are wanting sort by x
and then y, you just want something like this:

sorttest.sort{ a, b -> a.x == b.x ? a.y <=> b.y : a.x <=> b.x }
sorttest.sort{ a, b -> a.x == b.x ? b.y <=> a.y : b.x <=> a.x } //
reverse of above

On Mon, May 20, 2024 at 6:43 AM M.v.Gulik <[email protected]> wrote:
>
> Hmm. Same deal with Float values.
>
> (Guess I'm down to enforce BigDecimal values in case of sorting with
> Float or Double values.)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.