-(IBAction)onPeriodChanged:(id)sender
{
NSDictionary * data1 = @{@"value":@"0"};
NSDictionary * data2 = @{@"value":@"2.2"};
NSDictionary * data3 = @{@"value":@"2.1"};
NSDictionary * data4 = @{@"value":@"8.1"};
NSDictionary * data5 = @{@"value":@"3.2"};
NSDictionary * data6 = @{@"value":@"9.0"};
NSArray * arr = @[data1,data2,data3,data4,data5,data6];
NSLog(@"arr==%@",arr);
NSArray * sortArr = [arr sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
float obj1Number = [[obj1 numberForKey:@"value"] floatValue];
float obj2Number = [[obj2 numberForKey:@"value"] floatValue];
float cha = obj1Number - obj2Number;
/*
{NSOrderedAscending = -1L, NSOrderedSame, NSOrderedDescending}
*/
if (cha >= 0) {
return NSOrderedDescending;
}
return NSOrderedAscending;
}];
NSLog(@"sortArr==%@",sortArr);
}