Skip to content

Commit

Permalink
simplify method and terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbduncan committed Oct 12, 2023
1 parent 5f71d0f commit a0839cc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -2132,16 +2132,13 @@ def sort_by_column_keys(
result = itemgetter(*columns)(row_data)
return result

_key = key
if key:

def _key(row: tuple[RowKey, dict[ColumnKey | str, CellType]]) -> Any:
_, row_data = row
return key(itemgetter(*columns)(row_data))
def key_wrapper(row: tuple[RowKey, dict[ColumnKey | str, CellType]]) -> Any:
_, row_data = row
return key(itemgetter(*columns)(row_data))

ordered_rows = sorted(
self._data.items(),
key=_key if key is not None else sort_by_column_keys,
key=key_wrapper if key is not None else sort_by_column_keys,
reverse=reverse,
)
self._row_locations = TwoWayDict(
Expand Down

0 comments on commit a0839cc

Please sign in to comment.