Sign in Join
Wiki copytemporary

NaturalSort/fr: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11# A propos
22
33Le tri naturel est un classement de chaînes e caractères en ordre alphabétique, sauf que les nombres à plusieurs chiffres sont ordonnés comme un caractère simple. L'ordre de tri naturel a été présenté plus convivial ("naturel") que le pur ordre alphabétique orienté machine.
44
55Par exemple, dans un tri alphabétique "z11" sera placé devant "z2" parce "2" est pris pour plus grand que "1", alors qu'avec le tri naturel "z2" sera placé avant "z11" car "2" est considéré plus petit que "11".
66
77La possibilité de trier selon l'ordre naturel est disponible dans plusieurs langages et bibliothèques.
88
99# Auteurs
1010
1111Antônio Galvão et Rik van Kekem
1212
1313# Plateformes
1414
1515**Linux** et **Windows**.
1616
1717# Propriétés
1818
1919##### Deux types de tri
2020
21-` type`\
22-`   TSortType = (stNatural, stFloatThousand);`
21+``` pascal
22+ type
23+ TSortType = (stNatural, stFloatThousand);
24+```
2325
2426Le numéros thématiques, entiers et adresses IP sont triés par le type de tri **stNatural**. Les milliers avec séparateurs et les nombres en virgule flottante sont triés par le type de tri **stFloatThousand**. Les deux font l'ordre alphabétique collationné et trient les nombres internes dans des chaînes alphabétiques.
2527
2628##### Tri alphabétique collationné (stNatural ou stFloatThousand) :
2729
2830Parties alphabétiques tri par OS (Windows or Linux).
2931
30-`    0o3ö6ãrõxögùmî1ó5egõ`\
31-`    1I8iuã0u4ô8EeU7öuOkü`\
32-`    3â0á0e6ùsunueUtö8írò`\
33-`    3áiokúdùsétöbïqãkôvI`\
34-`    4õ4îcë4ò0à1ólOaUpáxã`\
35-`    5î2ãgâoí8î4ü1ò3ïwowë`\
36-`    5úrüqUfò5u0íyïfü5âlí`
32+```text
33+ 0o3ö6ãrõxögùmî1ó5egõ
34+ 1I8iuã0u4ô8EeU7öuOkü
35+ 3â0á0e6ùsunueUtö8írò
36+ 3áiokúdùsétöbïqãkôvI
37+ 4õ4îcë4ò0à1ólOaUpáxã
38+ 5î2ãgâoí8î4ü1ò3ïwowë
39+ 5úrüqUfò5u0íyïfü5âlí
40+```
3741
3842##### Tri des numérateurs thématiques (stNatural) :
3943
40-`    1`\
41-`    1.1.1`\
42-`    1.1.2`\
43-`    1.2.1`\
44-`    1.99.99`\
45-`    2`
44+```text
45+ 1
46+ 1.1.1
47+ 1.1.2
48+ 1.2.1
49+ 1.99.99
50+ 2
51+```
4652
4753##### Tri des entiers (stNatural) :
4854
49-`    0`\
50-`    00`\
51-`    000`\
52-`    1`\
53-`    2`\
54-`    10`
55+```text
56+ 0
57+ 00
58+ 000
59+ 1
60+ 2
61+ 10
62+```
5563
5664##### Tri des adresses IP (stNatural) :
5765
58-`    10.145.254.9`\
59-`    10.145.255.9`\
60-`    10.145.255.10`\
61-`    10.146.254.9`\
62-`    121.243.100.0`\
63-`    255.255.255.254`
66+```text
67+ 10.145.254.9
68+ 10.145.255.9
69+ 10.145.255.10
70+ 10.146.254.9
71+ 121.243.100.0
72+ 255.255.255.254
73+```
6474
6575##### Tri des nombres en virgule flottante (stFloatThousand) :
6676
67-`    0,99`\
68-`    1`\
69-`    1,01`\
70-`    1,99`\
71-`    2`
77+```text
78+ 0,99
79+ 1
80+ 1,01
81+ 1,99
82+ 2
83+```
7284
7385##### Nombres avec milliers séparés (stFloatThousand) :
7486
75-`    1.198`\
76-`    1.199`\
77-`    1.199,50`\
78-`    1.200`\
79-`    1.201`\
80-`    1.101.300`
87+```text
88+ 1.198
89+ 1.199
90+ 1.199,50
91+ 1.200
92+ 1.201
93+ 1.101.300
94+```
8195
8296Les séparateurs de milliers et le séparateur décimal sont ceux par défaut du système.
8397
8498**C'est rapide. Voyez le temps comparé à d'autres fonctions :**
8599
86-`     StrCmpLogicalW: 1`\
87-`    WideCompareText: 1,238`\
88-`        NaturalSort: 0,746`
100+```text
101+ StrCmpLogicalW: 1
102+ WideCompareText: 1,238
103+ NaturalSort: 0,746
104+```
89105
90106# Téléchargement
91107
92108La dernière version est disponible là : <http://sourceforge.net/projects/lazarusfiles/files/naturalsort.zip/download>
93109
94110Un projet de démo est inclus.
95111
96112## Fonctions and Procédures
97113
98114#### procedure NaturalSort(aList: TStrings; SortType: TSortType);
99115
100116Cette procédure fournit une façon de trier une liste de chaînes directement, selon le type de tri choisi, stFloatThousand (pour le tri des nombres flottants et des nombres à séparateurs de milliers ou stNatural (pour tous les autres tris supportés).
101117
102118Exemple d'emploi :
103119
104-` procedure TForm1.Button1Click(Sender :TObject);`\
105-` begin`\
106-`   NaturalSort(Memo1.Lines, stNatural); `\
107-`   NaturalSort(Memo2.Lines, stFloatThousand); `\
108-` end;`
120+``` pascal
121+ procedure TForm1.Button1Click(Sender :TObject);
122+ begin
123+ NaturalSort(Memo1.Lines, stNatural);
124+ NaturalSort(Memo2.Lines, stFloatThousand);
125+ end;
126+```
109127
110128#### function UTF8NaturalCompareList(aList: TStringList; Index1, Index2: Integer): Integer;
111129
112130Exemple d'emploi :
113131
114-` procedure NaturalSort(aList: TStrings);`\
115-` var`\
116-`   L: TStringList;`\
117-` begin`\
118-`   L := TStringList.Create;`\
119-`   try`\
120-`     L.Assign(aList);`\
121-`     L.CustomSort(@UTF8NaturalCompareList);`\
122-`     aList.Assign(L);`\
123-`   finally`\
124-`     L.Free;`\
125-`   end;`\
126-` end;`
132+``` pascal
133+ procedure NaturalSort(aList: TStrings);
134+ var
135+ L: TStringList;
136+ begin
137+ L := TStringList.Create;
138+ try
139+ L.Assign(aList);
140+ L.CustomSort(@UTF8NaturalCompareList);
141+ aList.Assign(L);
142+ finally
143+ L.Free;
144+ end;
145+ end;
146+```
127147
128148#### function UTF8FloatThousandCompareList(aList: TStringList; Index1, Index2: Integer): Integer;
129149
130150Exemple d'emploi :
131151
132-` procedure FloatThousandSort(aList: TStrings);`\
133-` var`\
134-`   L: TStringList;`\
135-` begin`\
136-`   L := TStringList.Create;`\
137-`   try`\
138-`     L.Assign(aList);`\
139-`     L.CustomSort(@UTF8FloatThousandCompareList);`\
140-`     aList.Assign(L);`\
141-`   finally`\
142-`     L.Free;`\
143-`   end;`\
144-` end;`
152+``` pascal
153+ procedure FloatThousandSort(aList: TStrings);
154+ var
155+ L: TStringList;
156+ begin
157+ L := TStringList.Create;
158+ try
159+ L.Assign(aList);
160+ L.CustomSort(@UTF8FloatThousandCompareList);
161+ aList.Assign(L);
162+ finally
163+ L.Free;
164+ end;
165+ end;
166+```
145167
146168#### Function UTF8FloatThousandCompareText(const S1, S2: string): Integer;
147169
148170#### Function UTF8LogicalCompareText(const S1, S2: string): Integer;
149171
150172#### Function UTF8NaturalCompareText(const S1, S2: string): Integer;
151173
152174# Contrôles avec tri naturel
153175
154176Une **TNaturalListBox** et une **TNaturalComboBox** sont fournies dans le projet de démo.
155177
156178---
157179*From the Free Pascal wiki, page "NaturalSort/fr", as it stood on 2016-11-17 after a change by E-ric, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history