Postico icon indicating copy to clipboard operation
Postico copied to clipboard

Order by multiple columns

Open firedev opened this issue 8 years ago • 2 comments

What do you think about the ability to order table by multiple columns?

Just thinking, say we have a table:

parent_id   | position   | title
------------+------------+-------- -- -
1           | 1          | First in First
2           | 1          | First in Second
1           | 2          | Second in First
2           | 2          | Second in Second

So I click parent_id:

parent_id ▲ | position   | title
------------+------------+-------- -- -
1           | 2          | Second in First
1           | 1          | First in First
2           | 2          | Second in Second
2           | 1          | First in Second

Then, say, shift-click position:

parent_id ▲ | position ▲ | title
------------+------------+-------- -- -
1           | 1          | First in First
1           | 2          | Second in First
2           | 1          | First in Second
2           | 2          | Second in Second

Then, click position:

parent_id ▲ | position ▼ | title
------------+------------+-------- -- -
1           | 2          | Second in First
1           | 1          | First in First
2           | 2          | Second in Second
2           | 1          | First in Second

Click parent_id

parent_id ▼ | position ▼ | title
------------+------------+-------- -- -
2           | 2          | Second in Second
2           | 1          | First in Second
1           | 2          | Second in First
1           | 1          | First in First

Shift-click position

parent_id ▼ | position   | title
------------+------------+-------- -- -
2           | 2          | Second in Second
2           | 1          | First in Second
1           | 2          | Second in First
1           | 1          | First in First

Hope that makes sense. Shift click adds/removes columns to/from the group. To make things simple we can assume that order of sort is always from left to right and if you need to order for position and then by parent_id you will have to swap columns.

firedev avatar Mar 03 '17 03:03 firedev

I like this. Since the rows are able to be reordered, they could just be ordered with the same order as the appear in the table. However, command-clicking would be preferable, since it's used for multiple selections, whereas control-clicking is generally for selecting a range from the first item to the last.

barrycenter avatar Mar 09 '17 03:03 barrycenter

+1! 🙏

andresgariglio avatar Aug 05 '21 19:08 andresgariglio

I added support for sorting by multiple columns in Postico build 9666.

You can download the latest build from the changelog

I came up with a different interface. Columns are sorted in the order they are clicked. The sort priority is displayed with a little number next to the sort indicator. You can change the sort priority by right-clicking on the table.

I did not want to add any modifier-clicking (shift, cmd) since that is hard to discover.

jakob avatar Nov 14 '23 13:11 jakob