Bug 167173 - When rectangular block is broken, relying on Calc to find the sort area itself leads to unexpected result
Summary: When rectangular block is broken, relying on Calc to find the sort area itsel...
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
25.2.4.3 release
Hardware: All macOS (All)
: medium normal
Assignee: Not Assigned
URL: https://ask.libreoffice.org/t/calc-ce...
Whiteboard:
Keywords:
Depends on:
Blocks: Sorting
  Show dependency treegraph
 
Reported: 2025-06-23 14:08 UTC by Sam
Modified: 2025-11-11 15:01 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample (from AskLibreOffice) (26.56 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-06-23 19:14 UTC, Telesto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sam 2025-06-23 14:08:55 UTC
In the attached *.ods file, cells in column C contain a header (= seqpre) and the digits 1, 2, and 3. I need Calc to sort column C in ascending order.

When starting the sort dialog, I have some single cell focused in the area, i.e., I don’t select my data manually – neither A1:CC1883, nor whole columns A:C; I rely on Calc to find the area itself, even though my cells A1882 and A1883 are empty, so the rectangular block is broken.

The result is that column C sorts correctly except for the last 2 cells (C:1882 and C:1883). Apparently empty cells in the first column are OK if they occur in the middle but not if they occur in the end, even though the other columns allow to deduce the correct rectangle.

Sort Criteria:
Sort Key 1:
Column [seqpre] (ascending)

Sort Key 2:
- undefined -

Sort Options:
Headers: Range contains column labels YES
Direction: Top to bottom (sort rows) YES

Options:
Case sensitive ON
Enable natural sort ON
Comment 1 Sam 2025-06-23 14:16:57 UTC
Can't attach the ods file, so I added a link to the Ask site.
Comment 2 m_a_riosv 2025-06-23 15:08:25 UTC
Please attach a sample file, reduce the size as much as possible without private information,
and paste the information in Menu/Help/About LibreOffice, there is a copy icon.


https://ask.libreoffice.org/t/calc-cells-excluded-from-sort/123436
Comment 3 Telesto 2025-06-23 19:14:53 UTC
Created attachment 201433 [details]
Sample (from AskLibreOffice)
Comment 4 Telesto 2025-06-23 19:16:48 UTC
Seems to be solved already: https://ask.libreoffice.org/t/calc-cells-excluded-from-sort/123436
Comment 5 Sam 2025-06-23 21:00:05 UTC
(In reply to Telesto from comment #4)
> Seems to be solved already:
> https://ask.libreoffice.org/t/calc-cells-excluded-from-sort/123436

The solution in https://ask.libreoffice.org/t/calc-cells-excluded-from-sort/123436/4?u=jeshkhol shows how by choosing Select All the problem can be avoided. For the user who doesn't know this the problem will persist.
Comment 6 Sam 2025-06-23 21:01:18 UTC
Version: 25.2.4.3 (X86_64) / LibreOffice Community
Build ID: 33e196637044ead23f5c3226cde09b47731f7e27
CPU threads: 4; OS: macOS 12.7.6; UI render: Skia/Raster; VCL: osx
Locale: en-GB (en_GB.UTF-8); UI: en-US
Calc: threaded
Comment 7 Regina Henschel 2025-11-11 15:01:37 UTC
I think bug 132521 is related, because currently the user has no information inside the sort dialog which cell range is actually determined by the auto-detection.

The attached document has a similar problem as bug 132521. It has defined a database range "loc_line" for A1:CC1881. And that one seems to be used by auto-detection. If you modify this database range to cover A1:CC1883, then the two rows with blanks in column A are included. The first step in auto-detection seems to be, to look whether there exists a database range that contains the active cell.