def sort(self, cmp=None, key=None, reverse=False):

    def _DefaultKey(value):
      """Default key func is to create a list of all fields."""
      result = []
      for key in self.header:
        # Try sorting as numerical value if possible.
        try:
          result.append(float(value[key]))
        except ValueError:
          result.append(value[key])
      return result

    key = key or _DefaultKey
    # Exclude header by copying table.
    new_table = self._table[1:]
    new_table.sort(cmp, key, reverse)
    # Regenerate the table with original header
    self._table = [self.header]
    self._table.extend(new_table)
    # Re-write the 'row' attribute of each row
    for index, row in enumerate(self._table):
      row.row = index
  # pylint: enable=W0622
Sorts rows in the texttable.
dataset/ETHPy150Open google/textfsm/texttable.py/TextTable.sort