def sortdict(dict):
 items = dict.items()
 items.sort()
 reprpairs = [('%r: %r' % pair) for pair in items]
 withcommas = ', '.join(reprpairs)
 return ('{%s}' % withcommas)

def sortdict ( dict ) : items = dict . items ( ) items . sort ( ) reprpairs = [ ( '%r: %r' % pair ) for pair in items ] withcommas = ', ' . join ( reprpairs ) return ( '{%s}' % withcommas )
like repr .