2011-05-23 83 views

回答

2
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; 
    } 
}