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

OCsite <[email protected]>
Newsgroups gmane.comp.lang.groovy.user
Message-ID <[email protected]>
In general, this is not a safe approach, unless you are sure that the sorting algorithm is stable (never reordering items regarded „same“).

I regret to say I do not know whether Groovy sort is documented to be always stable or not.

All the best,
OC


> On 21. 5. 2024, at 7:12, 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.
> 
> 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.)
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.