Subject says it all.
Regard that the feature also works with data containing more than one numerical part.
If somebody is interested in the background:
- There were related questions (one by myself) because sort descriptors don’t support
natural sort
currently. - @Regina is concerned with tdf#161948
- As the name says,
natural sort
only treats natural numbers by their values.
There may be cases where a user wants sorting by value (instead of alphanumeric) for non-natural numbers embedded in strings. - Not liking avoidable specialisations (and in a somehow playful mood) I wrote user code for a
SORTBYWITHVALUES()
applicable to strings with embedded numbers in any standard format.DATE
,TOD
are not treated this way.
There is an example containg the code (and a few helpers).
sortByWithValues.ods (30.4 KB)
If you use a daily build you will get already attribute NumberBehavior
in css::sheet::SheetSortDescriptor2. It uses the constants in group css::sheet::SortNumberBehavior. Only that the constant INTEGER is not yet implemented, but that is work in progress.
If you want to sort by “Natural Sort” in a released build, you can do this by dispatcher. The UI checkbox has the corresponding parameter NaturalSort
in SID_SORT (= .uno:DataSort). See an example of use in the attached file.
tdf161948_NaturalSort_OldWay.ods (16.1 KB)
It is specified in ODF 19.628 table:embedded-number-behavior Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 3: OpenDocument Schema
The implementation is in https://opengrok.libreoffice.org/xref/core/sc/source/core/data/table3.cxx?r=b0732e1ba9944a07aed737dcc52ef9e7614c38df#144
Currently the ODF value ‘integer’ is not implemented, but I’m working on it. I have also started a draft for a Wiki page, but that can only be finished, if the UX teams has decided about the user interface. User:Regina/Sandbox for additions to existing pages - The Document Foundation Wiki
Thanks!_