private void sink(int index) {
    if (index <= 0 || index > size) {
      return;
    }
    int left = index * 2;
    int right = index * 2 + 1;
    int largest = index;
    if (left <= size && less(index, left)) {
      largest = left;
    }
    if (right <= size && less(largest, right)) {
      largest = right;
    }
    if (largest != index) {
      swap(index, largest);
      sink(largest);
    }
  }