NSDictionary Sort Key

-(NSArray *)sort:(NSDictionary *)dictionary

{

    NSArray *allKeys = [dictionary allKeys];

    

    NSStringCompareOptions comparision = NSCaseInsensitiveSearch | NSNumericSearch | NSWidthInsensitiveSearch |NSForcedOrderingSearch;

    

    NSArray *sortedKeys = [allKeys sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {

        return [obj1 compare:obj2 options:comparision];

    }];

    

    return sortedKeys;

}


排序nsdictionary,返回key的nsarray。根据keyarry取value。

你可能感兴趣的:(Objective,C)