zoukankan      html  css  js  c++  java
  • oc 字典应用实例-成绩科目排序

     1  NSMutableArray *mutArray1 = [[NSMutableArray alloc]init];
     2         NSDictionary *dic = [[NSDictionary alloc]initWithObjectsAndKeys:[NSNumber numberWithInt:98],@"chinese", [NSNumber numberWithInt:68],@"math",[NSNumber numberWithInt:108],@"english",[NSNumber numberWithInt:58],@"politics",nil];
     3         NSArray *array = [dic allValues];
     4         NSLog(@"%@",array);
     5         array = [array sortedArrayUsingSelector:@selector(compare:)];
     6         NSLog(@"%@",array);
     7 //        NSArray *array1 = [dic allKeysForObject:[NSNumber numberWithInt:98]];
     8 //        NSString *str2 = [array1 objectAtIndex:0];
     9 //        NSLog(@"%@",str2);
    10         for (int i = 0; i < array.count; i ++)
    11         {
    12             NSArray *array2 = [dic allKeysForObject:[array objectAtIndex:i]];//在排好序数组中按照值取键
    13             NSString *str2 = [array2 objectAtIndex:0];//在数组中把键取出
    14             [mutArray1 addObject:str2];//取出的键加到新的数组中
    15         }
    16         NSLog(@"mutArray2 = %@",mutArray1);
    17     }
  • 相关阅读:
    nginx反向代理
    遇到的好玩的mvc路由
    有意思的OWIN,附脱离iis的webapi
    nginx转发配置
    SQL 2016安装中遇到的问题
    3级级联 国家--城市
    box.css
    common.css
    节假日设置
    Order_Leave.aspx
  • 原文地址:https://www.cnblogs.com/song-kl/p/4463929.html
Copyright © 2011-2022 走看看