What I would like to achieve is:
1. Grab the NSStrings from all the NSDictionaries from my NSArray (Only one NSString per NSDictionary)
2. Then sort all the NSStrings so that all the Names are sorted alphabetically.
For example:
Say there is Mark, Nick, and Rob. There are 6 NSDictionaries in my array (Each player having 2 nsdictionaries). So it would look like this (Randomized):
Mark, Rob, Nick, Nick, Rob, Mark
I want to sort it like this:
Mark, Mark, Nick, Nick, Rob, Rob
Is this possible? How would I do this?
Thanks!
What you first need is an array of the names. Let’s assume that “dictionaryArray” is the name of your array of dictionaries, and that “name” is one of the keys in each of your dictionaries:
Next, you sort this array. In this particular example, you’re actually producing a sorted immutable copy of it:
If instead you wanted a mutable array to sort, after creating the array “names,” you could make a mutable version of it:
And then you could sort it in place with:
Good luck to you in your endeavors.