2012-11-07 93 views

回答

1
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"placeDistance" ascending:TRUE]; 
[your array sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]] 
+0

thnaks其工作.. –

+0

我的榮幸@Ranjan薩胡 –

0
NSArray* array... 
NSArray* sorted_array = [array sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { 
    YourClass* a = (YourClass*)obj1; 
    YourClass* b = (YourClass*)obj2; 
    /* 
    return NSComparisonResult based on a property comparison here, 
    for example, return [a.distance compare:b.distance] if distance is an NSNumber 
    */ 
}]; 

就像Sort ignoring punctuation (Objective-C)

相關問題