Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[collections-dev] Sort primitives with a comparator

Hello,

I recently started using GS/Eclipse collections.  It is like a breath of fresh air.  Thank you for all of your hard work.

In the primitive collections, such as MutableIntList, I see a sortThis() method.  I looked at the impl and I see it calls Arrays.sort() directly on the underlying array.  I did not see a version that takes a primitive comparator.

It has always been a sore spot with me that Java does not natively support Arrays.sort(<PrimitiveArray>, <PrimitiveComparator>).

I was considering to derive from the TimSort that Java 8 uses and contribute, but I don't know if there is a license conflict.  If GPL2 + linking exception doesn't work, is there another impl of sorting for generics that can easily be adapted for primitives?

Finally, I looked at the Java 8 impl for primitive array sorting.  Adapting that code to accept a primitive comparator looks much more challenging.

Kindly let me know what you think.

Thanks,
Arpe
Hongkong

Back to the top