I would like to sort an array of custom objects based on the name(NSString) variable. The name variable can have numbers in the end.
Unsorted data: Tank 1, Tank 2, Tank 10, Tank 32, Tank 3, Tank 11
I used the following sort descriptor,
[NSSortDescriptor sortDescriptorWithKey:@"objectName" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]
The resultant array gives: Tank 1, Tank 10, Tank 11, Tank 2, Tank 3, Tank32
But I need to get the array based on the actual numbers also, I mean the resultant array should be: Tank 1, Tank 2, Tank 3, Tank 10, Tank 11, Tank 32.
What change needs to be made to the sort descriptor to accomplish this?. Could someone help me on this.