private static int Partition(List <IComparable> list, int lo, int hi) { int i = lo; int j = hi + 1; IComparable v = list[lo]; while (true) { //向右扫描直到找到大于v的值 while (list[i++].Less(v)) { if (i == hi) { break; } } //向左扫描直到找到小于v的值 while (v.Less(list[--j])) { if (j == lo) { break; } } //i与j相遇 if (i >= j) { break; } list.Exch(i, j); } list.Exch(lo, j); return(j); }