object版的快排
#import "QuickSort.h" @implementation QuickSort -(int)helpMethod:(NSMutableArray*)array left:(int)left right:(int)right{ NSNumber* record=array[left]; while (left<right) { while (left<right&&array[right]>=record) { right--; } array[left]=array[right]; while (left<right&&array[left]<=record) { left++; } array[right]=array[left]; } array[left]=record; return left; } -(void)main:(NSMutableArray *)array left:(int)left right:(int)right{ if (left<right) { int middleIndex=[self helpMethod:array left:left right:right]; [self main:array left:left right:middleIndex-1]; [self main:array left:middleIndex+1 right:right]; } } @end