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 <mvgu...@gmail.com> 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.)

Reply via email to