code: def to_display_list(pairs, sort_by="key", allow_empty=True):
      dl = DisplayList()
      if isinstance(pairs, basestring):
          pairs = [pairs, pairs]
      for pair in pairs:
          if isinstance(pair, (tuple, list)):
              dl.add(*pair)
          if isinstance(pair, basestring):
              dl.add(*pairs)
              break
      if allow_empty:
          dl.add("", "")
      if sort_by == "key":
          dl = dl.sortedByKey()
      elif sort_by == "value":
          dl = dl.sortedByValue()
      return dl