Einzelnen Beitrag anzeigen

Daniel
(Co-Admin)

Registriert seit: 30. Mai 2002
Ort: Hamburg
13.919 Beiträge
 
Delphi 10.4 Sydney
 
#6
  Alt 20. Jan 2003, 11:03
Hallo,

erstmal willkommen in der Delphi-PRAXiS.

Die Stringliste bietet Dir die Eigenschaft 'CustomSort' an, mit welcher Du sie in einer von Dir gewünschten Reihenfolge sortieren kannst.

Zitat von Delphi-Hilfe:
Sorts the strings in the list in a customized order.

Delphi-Quellcode:
type TStringListSortCompare = function(List: TStringList; Index1, Index2: Integer): Integer;
procedure CustomSort(Compare: TStringListSortCompare); virtual;
Description:
Use CustomSort to sort the strings in the list, where the sort order is defined by the Compare parameter.

Supply a value for the Compare function that compares two strings in the string list. The List parameter provides access to the string list, while the Index1 and Index2 parameters identify the strings to be compared. Use Index1 and Index2 as indexes into the Strings property array. The Compare function should return

a value less than 0 if the string identified by Index1 comes before the string identified by Index2
0 if the two strings are equivalent
a value greater than 0 if the string with Index1 comes after the string identified by Index2.
Do not pass nil as the value of the Compare parameter.

Note: You must explicitly call the CustomSort method. Setting the Sorted property only sorts strings using ANSI order, as implemented in the Sort method.
Daniel R. Wolf
mit Grüßen aus Hamburg
  Mit Zitat antworten Zitat