Recent

Author Topic: My NaturalSort unit  (Read 15272 times)

BeniBela

  • Hero Member
  • *****
  • Posts: 947
    • homepage
Re: My NaturalSort unit
« Reply #30 on: May 26, 2015, 06:10:37 pm »
Or full Unicode support

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: My NaturalSort unit
« Reply #31 on: May 26, 2015, 06:55:38 pm »
Floating point sort is bonus enough. Pure natural sort does not do it.

Perhaps I cut even this, because it conflicts with other sort types.
« Last Edit: May 26, 2015, 07:00:03 pm by typo »

JD

  • Hero Member
  • *****
  • Posts: 1908
Re: My NaturalSort unit
« Reply #32 on: May 26, 2015, 07:12:29 pm »
Floating point sort is bonus enough. Pure natural sort does not do it.

Perhaps I cut even this, because it conflicts with other sort types.

Floating point sort is the main reason why I got interested.
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: My NaturalSort unit
« Reply #33 on: May 26, 2015, 07:31:59 pm »
Well, the main thing that this floating point sort routine does is, instead of multiplying Result by 10 as it does with integers, it divides the increased amount by 10 after reaching a decimal separator. This way the function returns a double numerical value which can be compared with another.

For integer values:

     First char: '1'
Second char: '2'

So the number is 12. It is 1 * 10 + 2. (FirstChar * 10 + SecondChar).

But for floating values:

     First char: '1'
Second char: decimal separator
   Third char: '2'

So the number is 1.2. It is 1 + 2 / 10. (FirstChar + SecondChar / 10).

And Count is the distance between the current char and the decimal separator.

So the routine "translates" the char to its numerical value.
« Last Edit: May 26, 2015, 08:33:18 pm by typo »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: My NaturalSort unit
« Reply #34 on: May 27, 2015, 05:51:29 am »
New arrangement of the unit allows thousand separators and floats again.

http://sourceforge.net/projects/lazarusfiles/files/naturalsort.zip/download
« Last Edit: May 27, 2015, 12:41:58 pm by typo »

PeterX

  • Sr. Member
  • ****
  • Posts: 437
Re: My NaturalSort unit
« Reply #35 on: January 30, 2025, 09:51:06 pm »
AFAIK, StrCmpLogicalW does the job on Windows and naturalstrcmp does it on Linux.
Looks like user typo was last active in 2015.

Does StrCmpLogicalW do the job ?
Has anybody worked with that, under Windows ?
usually using latest Lazarus release version with Windows 10 or 11

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: My NaturalSort unit
« Reply #36 on: January 30, 2025, 10:12:13 pm »
AFAIK, StrCmpLogicalW does the job on Windows and naturalstrcmp does it on Linux.
Does StrCmpLogicalW do the job ?
Has anybody worked with that, under Windows ?
As far as I can remember... Yes it works.

Here is another topic related to this topic...
https://forum.lazarus.freepascal.org/index.php/topic,28310.0.html

PeterX

  • Sr. Member
  • ****
  • Posts: 437
Re: My NaturalSort unit
« Reply #37 on: February 01, 2025, 02:13:06 pm »
Thank You !

So I will give it a try and compare the results to ol' naturalsortunit  :)
usually using latest Lazarus release version with Windows 10 or 11

 

TinyPortal © 2005-2018