import java.util.Comparator;
public class LengthComparator implements Comparator<String> {
public int compare(String x, String b) {
return x.length() - b.length();
}
}
Runtime is O(N log N), same as regular heapsort
Extra: the bottom-up heapification is Theta(N) in the worst case
Memory complexity is Theta(1)
Has bad cache performance