objective c - Sorting array of objects by two criterias? -


i have array of objects want sort 2 keys. objects lets of type student , properties i'm intrested in sort grade , name.

student {     double grade;     string name;     ... }  

how can sort objects first grade , name? example if have list: tom 9.9 andrew 9.8 chriestie 10 mat 9.8 allison 10 ada 9.8

after sort should have: allison 10 christie 10 tom 9.9 ada 9.8 andrew 9.8 mat 9.8

and not christie 10 allison 10 tom 9.9 andrew 9.8 ada 9.8 mat 9.8

any pointer helpful.

i'm pretty flakey on objective-c knowledge there's pointers here , there's documentation. here's crack @ it...

nssortdescriptor *gradesorter = [[nssortdescriptor alloc] initwithkey:@"grade" ascending:yes]; nssortdescriptor *namesorter = [[nssortdescriptor alloc] initwithkey:@"name" ascending:yes];  [personlist sortusingdescriptors:[nsarray arraywithobjects:gradesorter, namesorter, nil]]; 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -