This looks a bit too specialized to be a helper method, maybe its signature should be
`<T> sort(ObjectArrayList<T> list, Comparator<? super T> comparator)`?

Which makes me remember this method already exists in Lucene's CollectionUtil but with a `java.util.List` instead of an hppc `ObjectArrayList`. So maybe we should use an ArrayList instead of an ObjectArrayList to accumulate doc values and use this method to sort values?