I'm trying to sort a few (Mutable
)IntList
objects. The cost of boxing/unboxing integers is relevant in my program (which is exactly why I am using the primitive collections). I want to sort by the following criteria:
- All negative numbers come before non-negative numbers
- Smallest (closest to zero) numbers first
[1, 7, 0, -9, -3] -> [-3, -9, 0, 1, 7]
Is there a sorting method for the IntList
class in the Eclipse Collections library that allow a custom comparator? So far I have not found it, but the list of defined symbols is large, the search box only matches exact strings and documentation is hardly existent (mostly automatically generated from method signatures, I believe).
My last resort is to write my own int-int comparator and sorting function, which is not a big deal, but I'd rather not.
Please do not waste your time writing a proof of concept sorter, as much as I'd appreciate it.. I know how to sort a list, I just can't figure out how to locate stuff in the Eclipse Collections documentation. If you can help with that, feel free to include it in your answer.