Bug 117372 - can't sort columns past blank row
Summary: can't sort columns past blank row
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:6.2.0 target:6.1.0.1
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-01 10:15 UTC by tempgoggle
Modified: 2018-06-07 07:26 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
sample spreadsheet to illustrate sort issue (8.18 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-05-02 08:53 UTC, tempgoggle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tempgoggle 2018-05-01 10:15:26 UTC
Description:
Here's a sample spreadsheet:
    A    B    C
1   x    y    z
2   a    b    c
3 <blank row>
4   q    w    e
5   d    e    f

If you sort on column B, keeping all of the data together, it should end up looking like this:
    A    B    C
1 <blank row>
2   a    b    c
3   d    e    f
4   q    w    e
5   x    y    z

Try to sort it by selecting column B and then menu item Data->Sort. It should ask if you want to sort the other columns with column B to keep them together. 



Steps to Reproduce:
1. Here's a sample spreadsheet:
    A    B    C
1   x    y    z
2   a    b    c
3 <blank row>
4   u    v    w
5   d    e    f

2. I want to sort on column B, but keep the data all together, so it ends up like this:

    A    B    C
1 <blank row>
2   a    b    c
3   d    e    f
4   u    v    w
5   x    y    z

2. so select column B, then menu item Data -> Sort

3. it asks the following:
"The cells next to the current selection also contain data....
Do you want to extend the sort range to A1:C2 or sort the 
currently selected range B1:B1048576?"
[extend selection] [current selection] [cancel]

4. We don't want 'current selection', e.g. just column B, because we want
all the data in each row to remain in the row. So 'extend selection'
is the only choice. But A1:C2 is wrong and you can see that it's wrong, because
it has highlighted the A1:C2 block. It should extend the block to include
all columns, e.g. A1:C1048576. Instead it has stopped after row 2, because
there is a <blank row> there. That's the problem. The selection has stopped on a blank row.

5. Click [extend selection] and on the next box, leave the settings as they are and click [Ok]

6. as expected, it only sorts A1:C2 and the result is:
    A    B    C
1   a    b    c
2   x    y    z
3 <blank row>
4   u    v    w
5   d    e    f

It only sorted rows 1-2, leaving 3-5 as is.


Actual Results:  
Sort this table on column B:

    A    B    C
1   x    y    z
2   a    b    c
3 <blank row>
4   u    v    w
5   d    e    f

Actual result is:
    A    B    C
1   a    b    c
2   x    y    z
3 <blank row>
4   u    v    w
5   d    e    f

Expected Results:
    A    B    C
1 <blank row>
2   a    b    c
3   d    e    f
4   u    v    w
5   x    y    z



Reproducible: Always


User Profile Reset: No



Additional Info:
Even if I manually select the row data by cells, e.g. the B1:B5 block and do the same operation, it still only 'extends' it to A1:C2, stopping selection again on the blank row.

I can't see any workaround to this bug, e.g. no way to sort the entire spreadsheet on a column and keep the adjacent columns synched' with the sort key in the sort column.

Version:
Version: 6.0.3.2 (x64)
Build ID: 8f48d515416608e3a835360314dac7e47fd0b821
CPU threads: 4; OS: Windows 10.0; UI render: default; 
Locale: en-US (en_US); Calc: group


User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; TBTE; rv:11.0) like Gecko
Comment 1 tempgoggle 2018-05-01 10:20:56 UTC
Sorry for the bad description. This is my first bug report. I started out entering the whole story in that field and then realized it should go in the other fields, but I forgot to delete the text in the Description. I don't see any way to edit the Description. Perhaps someone can do that for me?
Comment 2 Xisco Faulí 2018-05-01 19:38:47 UTC
Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. 
(Please note that the attachment will be public, remove any sensitive information before attaching it. 
See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)

I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided.
Comment 3 tempgoggle 2018-05-02 08:53:43 UTC
Created attachment 141827 [details]
sample spreadsheet to illustrate sort issue
Comment 4 tempgoggle 2018-05-02 08:56:38 UTC
ok, uploaded sample (really simple) and set status to UNCONFIRMED.

Allow me to be more succinct in my explanation of the problem:

When a COLUMN is selected for sorting, it should offer to extend the sort range to include all COLUMNs, not just all columns down to the first blank row.

I'm pretty sure that's the way it used to work some time ago. Something has changed.
Comment 5 raal 2018-05-04 04:48:29 UTC
Reproducible with Version 4.1.0.0.alpha0+, Version: 5.4.0.0.alpha0+ and LO 6.1master / Linux

I doesn't mean it's a bug, so leaving unconfirmed. You can select area manually. Please could you find version where it works as you want ("I'm pretty sure that's the way it used to work some time ago. Something has changed.") ?
Comment 6 Xavier Van Wijmeersch 2018-05-04 07:45:19 UTC
I can reproduce also with AOO, but not with gnumeric.
Gnumeric will select all cells with data in, so not stopping at the blank row.
Its including the blank row and when sorting the blank row move's down.

When selecting manually the blank row in A3 will go down to A5.

Version: 5.3.1.2
Build ID: e80a0e0fd1875e1696614d24c32df0f95f03deb2
CPU Threads: 8; OS Version: Linux 4.14; UI Render: default; VCL: kde4; Layout Engine: new; 
Locale: nl-BE (en_US.UTF-8); Calc: group

Version: 6.0.5.0.0+
Build ID: 09fa7200d41403e8687dc639dfe74299da808d2b
CPU threads: 8; OS: Linux 4.14; UI render: default; VCL: kde4; 
Locale: nl-BE (en_US.UTF-8); Calc: group
Comment 7 Eike Rathke 2018-06-05 15:08:41 UTC
The direct approach to sort all data in this example is to select the range A1:C5 before invoking Data -> Sort.

AFAIK no spreadsheet application sorts empty cells to the top, so that expectation doesn't hold.

However, when the entire columns (or the range B1:B5 for that matter) was selected then extending the selection could use the data range covered and extend from there to also include the neighbours and contiguous data.

Btw, the behaviour was the same already in OOo.

I also tried in Gnumeric 1.12.41 and that doesn't even ask to extend the selection but sorts only the selected column B.
Comment 8 Commit Notification 2018-06-05 19:06:22 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=5209f21b106a2c21770073d06616458d8e06031b

Resolves: tdf#117372 preserve preselected sort area, if so, then extend or not

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2018-06-06 08:04:14 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=98bd4ba9f186060ce1bc010838774fc4a73ee807&h=libreoffice-6-1

Resolves: tdf#117372 preserve preselected sort area, if so, then extend or not

It will be available in 6.1.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Xavier Van Wijmeersch 2018-06-06 18:03:10 UTC
its working with

Version: 6.1.0.0.beta1+
Build ID: 591933bf668b014055813edc75d5d4764c428e11
CPU threads: 8; OS: Linux 4.14; UI render: default; VCL: kde4; 
Locale: nl-BE (en_US.UTF-8); Calc: group threaded

I retested with gnumeric 1.12.34

@Eike "I also tried in Gnumeric 1.12.41 and that doesn't even ask to extend the selection but sorts only the selected column B." correct, but selecting A1 en press the sort button its sort the hole range A1:C5.
Comment 11 Eike Rathke 2018-06-07 07:26:27 UTC
(In reply to Xavier Van Wijmeersch from comment #10)
> [... Gnumeric ...] selecting
> A1 en press the sort button its sort the hole range A1:C5.
Which isn't the original problem. Anyway, won't implement that. It's logical to stop automatically selecting the data area at a row or column that does not contain data connected to the preselected area.