Bug #52561 Broken sorting
Submitted: 2 Apr 2010 20:01 Modified: 14 Jan 2014 2:27
Reporter: Todd Farmer (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.2.17 OS:Any (XP, Mac OS X)
Assigned to: Alfredo Kojima CPU Architecture:Any

[2 Apr 2010 20:01] Todd Farmer
Description:
When I select rows from a multi-column table, and select a cell in the second column and apply the "sort descending" icon, the data refreshes and my cursor moves to the top-leftmost cell.  Clicking the "sort ascending" or "sort descending" icons again causes the first column header to get the sort icon, but it also remains on the second column header, and the data doesn't appear to be sorting correctly any longer.

How to repeat:
See above.

Suggested fix:
Fix sorting.
[3 Apr 2010 15:31] Valeriy Kravchuk
Problem with sorting icon appearing on a second column (without removing sorting icon from the column data were previously sorted by) and resulting "wrong" sorting (if we interpret icons left to right) is verified on Mac OS X also.
[7 Apr 2010 14:03] Sergei Tkachenko
There is no problem with sorting. Just note that multiple sorting is enabled for user convenience by default (when using toolbar buttons), retaining existing sorted columns in 'order by' clause. As a result of the provided sequence rows are expected to be ordered by 2nd and then by 1st column.

Other things to note:
- If you don't want to retain existing sorting then sort by clicking on column headers instead. It's also possible to do multiple column sorting by clicking on column headers while holding Shift key.
- Order of columns in the columns list used to sort by is determined by order of first adding of the column to the list (either by header click or using toolbar button), that allows to change sort direction for specific column later without shifting it to the end of the 'order by' clause.
- Any column sorting is supposed to be reset by Alt+click on the corresponding column header.
[7 Apr 2010 14:57] Todd Farmer
That's good information about multiple-column sorting; it isn't readily apparent.

There is, however, still a bug:

CREATE TABLE test_sort( a INT, b INT);
INSERT INTO test_sort VALUES (1, 1), (1, 2), (2, 1), (2, 2);
SELECT * FROM test_sort;

Click on column a header (sort asc).
Shift-click on column b header (both columns sorted asc now)
Alt-click (or Ctrl-click, same result) on column a header (only column b sorted asc now)

Data no longer matches sort order shown in column headers.
[7 Apr 2010 15:47] Todd Farmer
I might also suggest a feature request to add a third sorting icon to explicitly cancel any sorts on the selected column.  That appears to be currently possible using keystrokes.
[7 Apr 2010 21:45] Sergei Tkachenko
Fix for processing of Shift-click is pushed in repository. Was not able to reproduce with Ctrl-click though, it's processed as expected, toggling sort order of the column and resetting sorting for other columns.
Ctrl-click has no special meaning and is considered as usual click. Initially it was used for descending sorting in windows version but then somebody disabled it later referring to cross-platform behavior unification. Now to sort descending user has to click header twice or use toolbar button.

Toolbar buttons will be added later.
[20 May 2010 16:23] Sergei Tkachenko
Added requested tool-button.
[14 Jan 2014 2:27] Philip Olson
Fixed as of the upcoming MySQL Workbench 6.1.1, and here is the changelog entry:

General sorting improvements were made to the SQL statement results
matrix, including changes to remove variances with different platforms. A
selected column stays set after a sort, and selecting a column while
holding "Shift" adds the column to the sort criteria, thus sorting by
multiple columns.

Thank you for the bug report.