How to get the feature `Enable natural sort` with a SortDescriptor for sorting a SheetCellRange

Enable natural sort is offered by the respective dialog and it seems to work with recorded macros. On the other hand there is no obvious way to get the needed collation when sorting API-based using a SortDescriptor.

I would like to know a probably existing “not quite obvious way”.

1 Like

Possibly TextSortDescriptor’s IsSortNumericN attributes are relevant? (I didn’t check the code, sorry)

Sorry. I couldn’t figure out how to try this.
The type setting Numeric per field has no effect insofar (as judged from my experiments).

There must be some property because My “QuickSort” extenstion (StarBasic with 2 toolbar buttons) merges db-range properties with sort descriptor properties before sorting the column at the active cell.

  1. Define database range with or without declared header row.
  2. Sort with natural sort option.
  3. Revert the sort order with my macro and natural sort will be retained.

However, I can not spot the property value which tells the program about natural sorting.

Hallo
Implement the “natural Sort” -function by yourself, for Example how it is done in the Sort AddInn thread
the final Version so far:
XPySort.ods change …ods to …oxt (4.7 KB)

Thanks.

To get (or to write myself) a collator for natural sort not accessible via the API wasn’t my intention.
I definitely wanted to get the advantages of the very efficient sorting implemented in LibO, of its readiness to include the collation of many fields in the needed order (seemingly in one go), and of the related application of locales.

As so often: I don’t urgently need the answer. I mainly want to know.
In addition I remind of my opinion that every feature available via the UI (and sometimes based on UI usage even via recorded macros) should be implemented in a way making it also accessible by calls to API methods. In fact LibO should work as if it actually does everything by API calls itself.

1 Like

The slot of the .uno:DataSort command has a parameter NaturalSort. Thus you can use NaturalSort via Dispatcher. (Do not forget to set Col1 in addition and remember that the column numbering starts with 1 in Basic not with 0.) But NaturalSort will become obsolete when LibreOffice will be able to use all three values provided by ODF. Related work is tracked in tdf#161948.

1 Like

Thanks for reporting and assigning yourself.