hello开发者_如何学JAVA I want to sort(ascending) some numbers stored in different variables(like int a=50,int b=60, etc..)! How can i do that? Thanks for any help!
You need to store the numbers in an NSArray, packaged in NSNumbers. Then you can do normal array sorting:
NSArray *array = [NSArray arrayWithObjects:
[NSNumber numberWithInt:a],
[NSNumber numberWithInt:b],
nil
];
NSArray *sorted = [array sortedArrayUsingSelector:@selector(compare:)];
Put them into NSArray or NSMutableArray and sort the array
精彩评论