CodeSnippet 112556 is locked.
Therefore here a kind of comment coming as a Calc document made with LibO V 25.2.1 Calc:
Comments on Natural Sort topic 112556
Comments on Natural Sort topic 112556
On Windows 10: LibreOffice 25.2.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Natural Sort. See topic 112556.
Spent a bit more time on this.
Preliminary result:
The items seem to be split in "numeric parts" and "non-numeric parts" in the order of occurrence. Sorting is then done in a way as if these parts are written into consecutive columns, and sorted by them with descending relevance from left to right.
If we assume that there is a maximum of 10 parts, in LibO Calc the formula
would create the column contents.
How signs are treated looks like a special mess to me. (Withdrawn remark.)
Decimal delimiters and signs seem to be treated as text ("," LT "." // "-" LT "+").
Preliminary result:
The items seem to be split in "numeric parts" and "non-numeric parts" in the order of occurrence. Sorting is then done in a way as if these parts are written into consecutive columns, and sorted by them with descending relevance from left to right.
If we assume that there is a maximum of 10 parts, in LibO Calc the formula
Code: Select all
{=IFNA(REGEX($B1; "\D+|\d+"; ; COLUMN(OFFSET(INDIRECT("$A$1"); 0; 0; 1; 10))); "")}Decimal delimiters and signs seem to be treated as text ("," LT "." // "-" LT "+").
Last edited by Lupp on Mon Mar 03, 2025 8:05 pm, edited 3 times in total.
On Windows 10: LibreOffice 25.2.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
- MrProgrammer
- Moderator
- Posts: 5347
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Natural Sort. See topic 112556.
Topic 112556 is Natural sort for OpenOffice Calc.
After reading the vague explanation of the behavior in the LO help, I decided: Not me. But I remembered the types of topics in the Calc forum which ask about natural sorting, even if they don't use that name, and realized that a simple 30-line StarBasic function which supports text followed by an unsigned integer would solve many of them, for example, How do I sort numerically with alpha prefix? and [Solved] Sort text1 through text19 correctly.
Wow! That's very interesting. Nice research. And a more complex StarBasic function could implement that behavior. But I choose let others create such a function. I locked the Code Snippets topic so discussion like this would stay separate from that simple idea and function, since I wasn't going to make any proposed changes to have it duplicate the undocumented behavior in LibreOffice. I think many people have situations which NSKEY supports, are looking for quick OpenOffice solutions, and don't want to wade through dialog that isn't relevant to those situations.
Ha Ha. Maybe the reason the behavior isn't documented is that the explanation would be so complicated that:
• it would need to be quite long,
• it would be difficult to understand.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.6, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
AOO 4.1.7 Build 9800, MacOS 13.7.6, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
Re: Natural Sort. See topic 112556.
Thanks for your interest and your comments.
I enhanced my example document to exemplify my "research results" to more detail: Of course, the REGEX() part will only work in LibreOffice Calc V 6.2 or higher.
There are also more then 3 levels of sorting. Not supported by AOO.
I enhanced my example document to exemplify my "research results" to more detail: Of course, the REGEX() part will only work in LibreOffice Calc V 6.2 or higher.
There are also more then 3 levels of sorting. Not supported by AOO.
On Windows 10: LibreOffice 25.2.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Natural Sort. See topic 112556.
On Windows 10: LibreOffice 25.2.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München