private static <T> void sink(T[] a, Comparator<T> c, int parent, int n)
    {
        while (true)
        {
            int left = parent * 2 + 1;
            if (left >= n)
            {
                return;
            }
            int right = left + 1;
            int child = right >= n ? left : c.compare(a[left], a[right]) >= 0 ? left : right;
            if (c.compare(a[parent], a[child]) >= 0)
            {
                break;
            }
            swap(a, parent, child);
            parent = child;
        }
    }