NSMutableArray* floats = [[NSMutableArray alloc] initWithObjects:[NSNumber numberWithFloat:256.0], [NSNumber numberWithFloat:9.0], [NSNumber numberWithFloat:1.0], [NSNumber numberWithFloat:4.0], [NSNumber numberWithFloat:10.0], [NSNumber numberWithFloat:900.0], nil]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES]; NSArray* sortedFloats = [floats sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]; for (NSNumber* num in sortedFloats) { NSLog(@"%f", [num floatValue]); }
No comments:
Post a Comment