'Sort the rows in this table, using the specified column\'s
values as a sort key.
:param column_index: Specifies which column to sort, using
either a column index (int) or a column\'s label name
(str).
:param order: Specifies whether to sort the values in
ascending or descending order:
- ``\'ascending\'``: Sort from least to greatest.
- ``\'descending\'``: Sort from greatest to least.
- ``\'toggle\'``: If the most recent call to ``sort_by()``
sorted the table by the same column (``column_index``),
then reverse the rows; otherwise sort in ascending
order.'

def sort_by(self, column_index, order='toggle'):

    if (order not in ('ascending', 'descending', 'toggle')):
        raise ValueError('sort_by():    order    should    be    "ascending",    "descending",    or    "toggle".')
    column_index = self.column_index(column_index)
    config_cookie = self._save_config_info(index_by_id=True)
    if ((order == 'toggle') and (column_index == self._sortkey)):
        self._rows.reverse()
    else:
        self._rows.sort(key=operator.itemgetter(column_index), reverse=(order == 'descending'))
        self._sortkey = column_index
    self._fill_table()
    self._restore_config_info(config_cookie, index_by_id=True, see=True)
    if self._DEBUG:
        self._check_table_vs_mlb()
