Sign in Join
Wiki copytemporary

NaturalSort/fr: what changed

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

Title: NaturalSort/fr

OldNewLine
1+# A propos
2+
3+Le 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.
4+
5+Par 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".
6+
7+La possibilité de trier selon l'ordre naturel est disponible dans plusieurs langages et bibliothèques.
8+
9+# Auteurs
10+
11+Antônio Galvão et Rik van Kekem
12+
13+# Plateformes
14+
15+**Linux** et **Windows**.
16+
17+# Propriétés
18+
19+##### Deux types de tri
20+
21+` type`\
22+`   TSortType = (stNatural, stFloatThousand);`
23+
24+Le 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.
25+
26+##### Tri alphabétique collationné (stNatural ou stFloatThousand) :
27+
28+Parties alphabétiques tri par OS (Windows or Linux).
29+
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í`
37+
38+##### Tri des numérateurs thématiques (stNatural) :
39+
40+`    1`\
41+`    1.1.1`\
42+`    1.1.2`\
43+`    1.2.1`\
44+`    1.99.99`\
45+`    2`
46+
47+##### Tri des entiers (stNatural) :
48+
49+`    0`\
50+`    00`\
51+`    000`\
52+`    1`\
53+`    2`\
54+`    10`
55+
56+##### Tri des adresses IP (stNatural) :
57+
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`
64+
65+##### Tri des nombres en virgule flottante (stFloatThousand) :
66+
67+`    0,99`\
68+`    1`\
69+`    1,01`\
70+`    1,99`\
71+`    2`
72+
73+##### Nombres avec milliers séparés (stFloatThousand) :
74+
75+`    1.198`\
76+`    1.199`\
77+`    1.199,50`\
78+`    1.200`\
79+`    1.201`\
80+`    1.101.300`
81+
82+Les séparateurs de milliers et le séparateur décimal sont ceux par défaut du système.
83+
84+**C'est rapide. Voyez le temps comparé à d'autres fonctions :**
85+
86+`     StrCmpLogicalW: 1`\
87+`    WideCompareText: 1,238`\
88+`        NaturalSort: 0,746`
89+
90+# Téléchargement
91+
92+La dernière version est disponible là : <http://sourceforge.net/projects/lazarusfiles/files/naturalsort.zip/download>
93+
94+Un projet de démo est inclus.
95+
96+## Fonctions and Procédures
97+
98+#### procedure NaturalSort(aList: TStrings; SortType: TSortType);
99+
100+Cette 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).
101+
102+Exemple d'emploi :
103+
104+` procedure TForm1.Button1Click(Sender :TObject);`\
105+` begin`\
106+`   NaturalSort(Memo1.Lines, stNatural); `\
107+`   NaturalSort(Memo2.Lines, stFloatThousand); `\
108+` end;`
109+
110+#### function UTF8NaturalCompareList(aList: TStringList; Index1, Index2: Integer): Integer;
111+
112+Exemple d'emploi :
113+
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;`
127+
128+#### function UTF8FloatThousandCompareList(aList: TStringList; Index1, Index2: Integer): Integer;
129+
130+Exemple d'emploi :
131+
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;`
145+
146+#### Function UTF8FloatThousandCompareText(const S1, S2: string): Integer;
147+
148+#### Function UTF8LogicalCompareText(const S1, S2: string): Integer;
149+
150+#### Function UTF8NaturalCompareText(const S1, S2: string): Integer;
151+
152+# Contrôles avec tri naturel
153+
154+Une **TNaturalListBox** et une **TNaturalComboBox** sont fournies dans le projet de démo.
155+
156+---
157+*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