Sorting Number using NSSortDescriptor
I got stuck in another problem again but after a long time. This time I have database (Core Data), having an attribute of numbers which contains integer numbers like 213879,123,4,345,56567 and so. I need to fetch data in ascending number order similar to like alphabetically order. I am doing this in way given below, fetchRequest.sortDescriptors=[NSArray arrayWithObject: [NSSortDescriptor sortDescriptorWithKey:@"numbers" ascending:YES selector:@selector(compare:)]]; but unfortunately it compares only the 1st digit of every number, mean if there are 2 numbers like 123 and 321 , it will compare 1