Sorting again after every insert is wasteful when you only ever need the smallest or largest item. A binary heap keeps the minimum at the top with O(log n) insert and remove, stored compactly in an array. Use it for task schedulers, merging k sorted lists and Dijkstra. It does not keep everything in sorted order and cannot search for an arbitrary value quickly, so use a TreeMap when you need that.