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

Paul King <[email protected]>
Newsgroups gmane.comp.lang.groovy.user
Message-ID <CAMbkE7QcbLRTWyDS4EAXiKA1c7aR4y48-49MDuX1df_xw7RMmQ@mail.gmail.com>
On Tue, May 21, 2024 at 3:13 PM M.v.Gulik <[email protected]> wrote:
>
> After fixing my local bug I rechecked the "*.sort{ a, b -> a.y == b.y ? -a.y <=> -b.y : a.x <=> b.x }" variant.
> Same result/conclusion.

In terms of referencing the properties, you'd want to swap the order
you have above, i.e. you'd not want to have y ? y : x but rather y ? x
: y or x ? y : x.
Also, the "*.sort" would only be needed if you have lists of lists of maps.

> However, on a hunch, I split in into two separate consecutive sorts. "*.sort{ a, b -> a.x <=> b.x }.sort{ a, b -> -a.y <=> -b.y }"
> So far this seems to do the job of fully sorting my 2d/coordinates set. (so far: no guaranties, as the used data set is somewhat limited and specific.)

This doesn't seem right as written. Perhaps you are abbreviating and
leaving out some info that I am missing.
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.