Created attachment 195166 [details] Material for natural sort test Open attached file. Data > Select Range > choose 'naturalSort' Data > Sort... > Tab Options, check 'Enable natural sort' > OK Data > Select Range > choose 'alphanumericSort' Data > Sort... > Tab Options, make sure 'Enable natural sort' is not checked > OK Save file. Reopen saved file. Data > Select Range > choose 'naturalSort' Data > Sort... > Tab Options. Error: 'Enable natural sort' is not checked. Open saved file in editor and inspect element <table:database-ranges> in content.xml. You will find two <table:database-range> elements, one for database range 'naturalSort' the other for database range 'alphanumericalSort'. Compare their child elements <table:sort>. Besides the cell addresses they are identical. The element for database range 'naturalSort' should have an attribute table:embedded-number-behavior (19.628, part 3, ODF 1.3) with value 'double' or 'integer'. This attribute is needed to specify, that natural sort has to be used. If you add it manually, it is not read. Support for this attribute is missing and thus the setting 'Enable natural sort' is lost on save/load.
Reproducible Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 7a5d0c413f37e02356d0bd1e1da7a9445ee25fe8 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 Aoo has no the option. It fails in LIbreOffice from the start. LibreOffice 3.3.0 OOO330m19 (Build:6) tag libreoffice-3.3.0.4
The import is in https://opengrok.libreoffice.org/xref/core/sc/source/filter/xml/xmlsorti.cxx. But the ScXMLSortContext has no suitable member yet. The export is in https://opengrok.libreoffice.org/xref/core/sc/source/filter/xml/XMLExportDatabaseRanges.cxx The property "case-sensitive" can be used as a kind of template to see what needs to done. I propose this as easyHack.
The specification of the ODF attribute table:embedded-number-behavior is in https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part3-schema/OpenDocument-v1.3-os-part3-schema.html#attribute-table_embedded-number-behavior
See also: https://ask.libreoffice.org/t/enable-natural-sort-by-default/105916/
The struct ScSortParam has the members bNaturalSort and aCollatorAlgorithm. The latter is e.g. used in German locale for sort algorithm 'Telefonbuch'. With a German local I see table:algorithm="alphanumeric" or table:algorithm="phonebook" in the ODF file source. As ODF has only this one attribute for the algorithm, we need to encode the bNaturalSort attribute into this string. We could use a ";" (or a "+" or a "|") sign as delimiter. So we could get table:algorithm="alphanumeric;naturalsort" or table:algorithm="alphanumeric" or table:algorithm="naturalsort". The export is in /core/sc/source/filter/xml/XMLExportDatabaseRanges.cxx The import would need to separate the tokens and extend ScXMLSortContext for the bNaturalSort property. The import is in core/sc/source/filter/xml/xmlsorti.cxx. I'm not sure whether we have "Natural Sort" already in the API.