Question: I have a dict of tuples such as: 

```
d = {'a': (3, 5), 'b': (5, 8), 'c': (9, 3)}  

```

I want to return the key of the minimum of the tuple values based on the tuple index. For example, if using tuple index = 0, then 'a' would be returned. if index = 1, then 'c' would be returned. I have tried using min(), for example 

```
min(d, key=d.get)

```

but am not sure how to manipulate it to select the tuple index to use. Although there are similar questions, I have not found an answer to this. Apologies in advance if this is a duped question, and please link to the answer. Thanks

Answer: 
Since multiple keys could have the same value, you might want to return a list of matching keys, not just a single key.

```
def min_keys(d, index):

    # Initialize lists
    values = []
    matches = []

    # Append tuple items to list based on index
    for t in list(d.values()):
        values.append(t[index])

    # If the item matches the min, append the key to list
    for key in d:
        if d[key][index] == min(values):
            matches.append(key)

    # Return a list of all keys with min value at index
    return matches

```
Dictionaries are unsorted and have no index. 

If you want the return the key alphabetically first you could use the ascii order:

```
print(chr(min([ord(key) for key in d.keys()])))

```