For your requirements, the easiest way is to create a new array of keys, sort it, and then use the array to refer to elements from the source dictionary.
(Note that myComparison is your own method that will compare the two keys).
NSMutableArray* tempArray = [NSMutableArray arrayWithArray:[myDict allKeys]]; [tempArray sortedArrayUsingSelector:@selector(myComparison:)]; for (Foo* f in tempArray) { Value* val = [myDict objectForKey:f]; }
Andrew Grant
source share