Using the Graph Facebook API with this code
[facebook requestWithGraphPath:@"me/friends" andDelegate:self];
Now I have an NSDictionary which is like this:
{data = (
{
id = 123456;
name = "Mark Zuckerberg";
},
{
id = 654321;
name = "Steve Jobs";
},
{
id = 13579;
name = "Bill Gates";
}
...
);
}
I want to sort this NSDictionary, but I know that is not possible.
Of course, I can create 2 NSArray (or NSMutableArray), one “array_id” and the other one “array_name”.
I’d like to sort “array_name”, but keeping the reference to the id.
For example, if my two arrays are something like this:
array_name = {"Mark", "Steve", "Bill};
array_id = {"123456", "654321", "13579"};
I want, at the end, something like this:
array_name = {"Bill", "Mark", "Steve"};
array_id = {"13579", "123456", "654321"};
What do you suggest me? Thanks!
It doesn’t look like you want to sort an
NSDictionary, you want to sort anNSArrayofNSDictionaryobjects that just so happens to itself be in anNSDictionary. You can simply extract this friends array as follows:Now you can do the following: