.. _sorting_editor:

Sorting editor
==============

Clicking on a column label in the data viewer is a convenient way to sort the database contents by a single column.  But sometimes you may want to sort by a combination of columns; sort by the content of column A, within groups of the same value of A sort by the content of column B, etc.  To do this or to sort by a column that isn't shown in the current view, you need to define a named sorting.

Sortings are defined using the sorting editor dialog, which is very similar to the :ref:`view editor <view_editor>` dialog.  At the top of the dialog is a text box containing the name of the sorting; changing this renames the sorting.  Below that is a table showing the names of all the columns in the database, with a checkbox next to each indicating whether or not it is to be sorted.  Click this checkbox to add or remove the column from the set of ones to be sorted.  The third column in the table shows either "Ascending" or "Descending" for checked rows, indicating which direction to sort in; click this indicator to change it to the opposite value.  The dialog has "Up" and "Down" buttons for moving the selected row up or down in the table, changing the sequence in which the columns are sorted.  The rows are sorted by the topmost checked column first, rows with the same value in that column are sorted by the next highest checked column, etc.  Click "OK"/"Done" to accept the currently shown settings or cancel out of the dialog to revert to the previous values (or to cancel adding a new sorting).
