Created attachment 196444 [details] file with database range to reproduce the sorting problem Open attached document. It has a database range. Set cursor to a data cell. Menu Data > Define... You get the "Define Database Range" dialog and the database range "myData" should be preselected. Open the "Options" section. Check "Contains totals row". Click on "Modify" button. OK [You need to do the above because of bug 162963.] Menu > Data > Select Range. Use "myData". OK. Menu > Data > Sort... Chose 'Age' as first key. Notice, the option "Headers: Contains column labels" is checked. But there exists no such option for "Contains totals row". OK Notice that the totals row has been moved by sorting. Request: (1) Make sorting a database range automatically detect, whether the database range has a totals row and exclude it from sorting. (2) Add an option "Totals: Contains totals row" to the "Sort..." dialog, so that it can be used too, if the to be sorted cell area is not a defined database range.
Currently struct ScSortParam has no member for totals row and I see the comment 402 /* TODO: add Totals to ScSortParam? */ in https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/dbdata.cxx
+1 Reproducible the scenario with Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 47a348bb0fd6dfdd93c1975d216daadc4f6b9b6f CPU threads: 16; OS: Windows 11 X86_64 (10.0 build 22631); UI render: Skia/Raster; VCL: win Locale: es-ES (es_ES); UI: en-US Calc: CL threaded