Skip to content

[Discussion] Multi-column sorting #1409

@Llaves

Description

@Llaves

at the suggestion of @justinclift , I'm including some thoughts on implementation.
Bearing in mind I have zero familiarity with the code:

It occurs to me this is a more complex issue than I would have
thought.

The log view suggests that column sorting is implemented by executing
an SQL query with "ORDER BY". The sort appears to be stable with
respect to table ordering, but the SQL standard explicitly states that
it is not a stable sort because a table is not defined as having an
ordering. So how do you achieve a multi-column sort? You could keep
track of column sorts and write a multi-column SQL statement, but this
is pretty clunky. How far back in the list do you go? How does a user
clear the list to get a sort on a single col? And of course, sorting
the same column twice in a row reverses the order, but what would that
mean if we are keeping track?

Another approach would be to create a temporary table with the sort
command and count on the fact the sqlite appears to use a stable sort.
This would die if sqlite ever dropped a stable sort because the
standard doesn't require it. Also, using a temporary table creates a
problem with the delete record button, since we're now viewing a temp
table, not the actual table in the database.

I suspect the best solution would be a sort dialog, kind of like
excel. You select the columns you want to sort and the direction
(up/down). This dialog then generates the appropriate SQL command.
Of course, you probably know all this already and that's why it hasn't
been implemented.

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions