code: def fmt_pairs(obj, indent=4, sort_key=None):
      lengths = [len(x[0]) for x in obj]
      if not lengths:
          return ''
      longest = max(lengths)
      obj = sorted(obj, key=sort_key)
      formatter = '%s{: <%d} {}' % (' ' * indent, longest)
      string = '\n'.join([formatter.format(k, v) for k, v in obj])
      return string