using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SomewhereIBelong { static class HeapSort where T :IComparable { public static void sort(ref T[] source) { int N = source.Length; for (int i = (N / 2) - 1; i >= 0; i--) siftDown(ref source, i, N); while (N >= 1) { exch(ref source, 0, --N); siftDown(ref source, 0, N); } } private static void siftDown(ref T[] source, int pos, int N) { while(2*pos+1