这是什么排序,感觉像快排
来自 sphinx
/// generic sorttemplate < typename T, typename F > void sphSort ( T * pData, int iCount, F COMP ){ int st0[32], st1[32], a, b, k, i, j; T x; k = 1; st0[0] = 0; st1[0] = iCount-1; while ( k ) { k--; i = a = st0[k]; j = b = st1[k]; x = pData [ (a+b)/2 ]; // FIXME! add better median at least while ( a<b ) { while ( i<=j ) { while ( COMP ( pData[i], x ) ) i++; while ( COMP ( x, pData[j] ) ) j--; if (i <= j) { Swap ( pData[i], pData[j] ); i++; j--; } } if ( j-a>=b-i ) { if ( a<j ) { st0[k] = a; st1[k] = j; k++; } a = i; } else { if ( i<b ) { st0[k] = i; st1[k] = b; k++; } b = j; } //fout << "a is\t" << a << "b is \t" << b << "i is \t" << i << "j is \t" << j <<endl; } }}