I think what you may be missing is that something like TreeSet or TreeMap is sorted *online*, so any sorting it does happens whenever you modify it (add or remove objects). What you're looking for is...