Tuesday, December 24, 2013

object-c array sort! ! ! Help! ! ! Where is the master


I created was stu1 stu2 stu3 stu4 stu5 in both the student's name and gender math scores put them all in an array
NSArray * array = [[NSArray alloc] initWithObjects: stu1, stu2, stu3, stu4, stu5, nil];
I want to sort the math
How should use the following method was modified ah ah how
NSArray * sortArray = [array sortedArrayUsingSelector: @ selector (compare :)];

Reply:
It is stored in the database, otherwise Gaosi you. .
Reply:
cited a floor mockqi reply:
stored in the database right, otherwise Gaosi you. .

My brother had just one week will not be so advanced OC was ah just learned this method trying to figure out how to use ah
Reply:
Rewrite compare methods stu class
Reply:
reference to the third floor waynell reply:
rewritten compare methods stu class,

Something you can say I'm not very good at detail ah. . . Thank you
Reply:
references, 4th Floor baofenghen reply:
reference to the third floor waynell reply:

Rewrite compare methods stu class,

Something you can say I'm not very good at detail ah. . . Thank you

 
- (NSComparisonResult) compare: (stu *) other {
if (⋯ ⋯) {
return NSOrderedDescending;
} Else if (⋯ ⋯) {
return NSOrderedAscending;
}
⋯ ⋯


Reply:
Well in fact almost bubble sort, you compare stu.math, then bubbling, you can get
Reply:
iphone technology exchange group, 4,633,616, welcome to explore.

No comments:

Post a Comment