先按conA排序,在conA相等的条件下再按conB排序:
- (void)fast:(NSInteger)beginIndex endIndex:(NSInteger)endIndex
{
if (beginIndex < endIndex)
{
model *key = array[beginIndex];
NSInteger low = beginIndex;
NSInteger heigh = endIndex;
while (low < heigh)
{
while ((low < heigh && ((model *)array[heigh]).conA > key.conA) ||(low < heigh && ((model *)array[heigh]).conA == key.conA && ((model *) array[heigh]).conB >= key.conB))
{
heigh--;
}
if (low < heigh)
{
array[low++] = array[heigh];
}
while ((low < heigh && ((model *)array[low]).conA < key.conA) || (low < heigh && ((model *)array[low]).conA == key.conA && ((model *) array[low]).conB < key.conB))
{
low++;
}
if (low < heigh)
{
array[heigh--] = array[low];
}
}
array[low] = key;
[self fast:beginIndex endIndex:low - 1];
[self fast:low + 1 endIndex:endIndex];
}
}