第六十八篇、OC_按照某一字段对数值进行排序

时间:2021-09-26 08:51:28

 

代码中是根据“create_time_” 进行排序   ascending:决定的是升序还是降序排序

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]initWithKey:@"create_time_" ascending:Yes];
  [dataArray sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];