Question: I have a dictionary with all employee IDs and their names in it. Now I want the user to select a name using the UIPickerView. Problem is: if I sort the values (the names) of the dictionary, how do I know which name corresponds to its ID as there could be identical names in the dictionary.

e.g.

```
{"0001", "John Doe"}
{"0002", "John Doe"}
{"0003", "Jane Doe"}
{"0004", "Jane Alpha"}
{"0005", "Jane Doe"}

```

So if I sort the resulting array with all the values and show this in the UIPickerView and select the third row (Jane Doe), how can I then get its corresponding ID?

Answer: 
Instead of creating two separate arrays for Name and IDs I created (as suggested by iDev) a custom object 'Person' with these 2 properties. I created a new Person object and added each one to an array.

Then I sorted that array using 

> 
> sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2)
> 
> 
> 

Then in titleForRow I return the Name of the person: 

> 
> ((Person \*)[mySortedArray objectAtIndex:row]).Name;
> 
> 
>
You can get selected dictionary as bellow

```
NSDictionary *aDict = [yourArrayName objectAtIndex:[self.yourPickerName selectedRowInComponent:0]];
NSLog(@"%@", aDict);

```