def key_of_max(d):
    """Return key associated with maximum value in d.

    >>> key_of_max({'a':1, 'b':2})
    'b'
    """
    keys = list(d.keys())
    keys.sort()
    return max(keys, key=lambda x: d[x])