is it possible to make multiple column sorting ?
I need to sort everything by date but display items with certain icon first.
is it possible to make multiple column sorting ?
I need to sort everything by date but display items with certain icon first.
You would likely have to associate your icons with something that determines your sort order (e.g., letter or number).
Then, apply Merrdydd’s 1st suggestion from the related post:
If you want to sort on multiple keys in python, you can do something like this:
sorted_on_two_columns = sorted(my_rows, key=lambda k: (k['column_1'], k['column_2']))
Here’s a clone that demonstrates sorting by letters only, then by letters and numbers:
yes it works perfectly for me, I just pull out rows with icon, organize them by date and put it together with the rest also organized by date…
Looks like you’ve got a working solution here, but I’d also like to chime in to say that you can sort by multiple columns in an app-tables.table.search(...)
operation.
This code will sort by col1
in descending order, and rows that have the same value for col1
will be sorted by col2
in ascending order:
x = app_tables.my_table.search(tables.order_by('col1', ascending=False),
tables.order_by('col2'))