def sorted_dict_repr(d):
 keys = list(d.keys())
 keys.sort()
 return (('{' + ', '.join([('%r: %r' % (k, d[k])) for k in keys])) + '}')

def sorted_dict_repr ( d ) : keys = list ( d . keys ( ) ) keys . sort ( ) return ( ( '{' + ', ' . join ( [ ( '%r: %r' % ( k , d [ k ] ) ) for k in keys ] ) ) + '}' )
repr() a dictionary with the keys in order .