Possible Duplicates:
best way to sort NSArray
Sort an array with special characters - iPhone
Hello,
I have array in which i have numbers stored as string.
How to sort this array in acsending order?
Possible Duplicates:
best way to sort NSArray
Sort an array with special characters - iPhone
Hello,
I have array in which i have numbers stored as string.
How to sort this array in acsending order?
NSArray *sortedArray = nil;
sortedArray = [oldArray sortedArrayUsingFunction:sortArray context:NULL];
NSInteger intSort(id num1, id num2, void *context) {
// OR: float n1 = [num1 floatValue]; etc.
int n1 = [num1 intValue];
int n2 = [num2 intValue];
if (n1 < n2) {
return NSOrderedAscending;
} else if (n1 > n2) {
return NSOrderedDescending;
} else {
return NSOrderedSame;
}
}