

def sort(self, cmp=None, key=None, reverse=False):
    'Sorts rows in the texttable.\n\n    Args:\n      cmp: func, non default sort algorithm to use.\n      key: func, applied to each element before sorting.\n      reverse: bool, reverse order of sort.\n    '

    def _DefaultKey(value):
        'Default key func is to create a list of all fields.'
        result = []
        for key in self.header:
            try:
                result.append(float(value[key]))
            except ValueError:
                result.append(value[key])
        return result
    key = (key or _DefaultKey)
    new_table = self._table[1:]
    new_table.sort(cmp, key, reverse)
    self._table = [self.header]
    self._table.extend(new_table)
    for (index, row) in enumerate(self._table):
        row.row = index

dataset/ETHPy150Open google/textfsm/texttable.py TextTable.sort/original