Optimizing insertion order when using a custom comparator.