@implementation NSString(compare)
-(NSComparisonResult)intCompare:(NSString *)other
{
int myValue = [self floatValue];
int otherValue= [other floatValue];
if (myValue == otherValue) {
return NSOrderedSame;
}
return (myValue < otherValue ? NSOrderedAscending : NSOrderedDescending);
}
@end
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
@"11111", @"1",
@"33333", @"3",
@"22222", @"2",
@"44444", @"4",
@"55555", @"5",
@"88888", @"8",
@"77777", @"7",
@"66666", @"6",
nil];
NSArray *key = [dict keysSortedByValueUsingSelector:@selector(intCompare:)];
NSLog(@"%@", key);
NSLog(@"%@", dict);