In my project I roll through a bunch of sql records and populate a NSMutableDictionary with a string for each key. The keys are important because I use them as section titles in my TableView.
The problem I have is that I would like the sections in a certain order. When I call allKeys the order of the keys isn't the same as the order they went into the NSMutableDictionary. I more or less understand why. My question is how I can make certain values (non alphabetically) appear first before the rest of the values.
Example strings: 'Blue', 'Brown', 'Green', 'Orange', 'Purple', 'Red', 'Violet', 'Yellow'...
I would like to see them ordered like this: 'Red', 'Green', 'Blue', 'Brown', 'Orange', 'Purple', 'Red', 'Violet'
The important part is the "'Red', 'Green', 'Blue'", all other values can be in alphabetical order behind those 3 values.
The only thing I can think of is to order them alphabetically by saying 'sortedArrayUsingSelector:@selector(compare:)' and then just trying to remove the strings I am looking for and placing them back in at a smaller index value if they exist. Any better ideas? I am not sure how efficient that is.