views:

377

answers:

3

Hi guys,

I have an object with different values that is name,nameid, lifebeging,lifeEndiging .... etc,

for loop
{
    // here i will get name, ids, other value for each object
    Search *Obj=[artistslist objectAtIndex:i];
}
0 obj.name=  //string values1 get from parser
1 obj.name=   //string values1
2 obj.name=  //string values1
3 obj.name=  //string values1
4 obj.name=  //string values1

I am getting values in the artistList then i need to sort only by name not other feilds

when i use this below statement

[artistsList sortUsingSelector:@selector(NSOrderedAscending:)];

i am getting exception here ,it is not working.

+2  A: 

isn't the correct selector to use localizedCaseInsensitiveCompare:?

jrtc27
A: 

From where you store the data in artistlist?

If you store it from Database then u can use ORDER BY query to sort...

Reena
I will store from xml parser
Madan Mohan
+1  A: 

NSOrderedAscending is not a selector, it's an enumeration constant and is one of the three possible return values the selector you do specify should return. For NSStrings, caseInsensitiveCompare: is a good one, or as jrtc27 suggests localizedCaseInsensitiveCompare: if you are sorting to present to the user. If not a string, you can define your own method that compares two objects and returns NSOrderedAscending, NSOrderedDescending or NSOrderedSame.

JeremyP
forgot about those ;) +1
jrtc27