Difference between revisions of "NaturalSort"

From Free Pascal wiki
Jump to navigationJump to search
(Created page with "{{Translate}} = About = Natural sort order is an ordering of strings in alphabetical order, except that multi-digit numbers are ordered as a single character. Natural sort or...")
 
Line 23: Line 23:
 
== Functions and Procedures ==
 
== Functions and Procedures ==
 
==== procedure NaturalSort(aList: TStrings); ====
 
==== procedure NaturalSort(aList: TStrings); ====
 +
Exemple of usage:
 +
 +
procedure TForm1.Button1Click(Sender :TObject);
 +
begin
 +
  NaturalSort(Memo1.Lines);
 +
end;
 +
 
==== function UTF8NaturalCompareList(aList: TStringList;  Index1, Index2: Integer): Integer; ====
 
==== function UTF8NaturalCompareList(aList: TStringList;  Index1, Index2: Integer): Integer; ====
 
==== function UTF8LogicalCompareText(const S1, S2: string): Integer; ====
 
==== function UTF8LogicalCompareText(const S1, S2: string): Integer; ====
 
==== function UTF8NaturalCompareText(const S1, S2: string): Integer;  ====
 
==== function UTF8NaturalCompareText(const S1, S2: string): Integer;  ====

Revision as of 19:40, 25 May 2015

Template:Translate

About

Natural sort order is an ordering of strings in alphabetical order, except that multi-digit numbers are ordered as a single character. Natural sort order has been promoted as being more human-friendly ("natural") than the machine-oriented pure alphabetical order.

For example, in alphabethical sorting "z11" would be sorted before "z2" because "2" is sorted as smaller than "1", while in natural sorting "z2" is sorted as smaller than "z11" because "2" is sorted as smaller than "11".

Functionality to sort by natural sort order is built into many progamming languages and libraries.

Authors

Antônio Galvão and Rik van Kekem

Platforms

Linux and Windows.

Download

The latest version is available here: http://sourceforge.net/projects/lazarusfiles/files/naturalsort.zip/download

Functions and Procedures

procedure NaturalSort(aList: TStrings);

Exemple of usage:

procedure TForm1.Button1Click(Sender :TObject); begin

 NaturalSort(Memo1.Lines);

end;

function UTF8NaturalCompareList(aList: TStringList; Index1, Index2: Integer): Integer;

function UTF8LogicalCompareText(const S1, S2: string): Integer;

function UTF8NaturalCompareText(const S1, S2: string): Integer;