TStringList.Sort

From Soldat Community Wiki
Revision as of 16:50, 23 August 2013 by Mighty (talk | contribs) (new page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
procedure Sort()

Description

This function will sort strings in TStringList alphabetically.
Note that this doesn't set Sorted to TRUE, so if you plan to add more strings and don't want to break the sorting, you have to set it to TRUE manually.

Example

var
  s: TStringList;

begin
  s := File.CreateStringList();
  s.Append('d');
  s.Append('a');
  s.Append('c');
  s.Append('ca');
  s.Append('b');

  WriteLn(s.CommaText);
  // d,a,c,ca,b 

  s.Sort();

  WriteLn(s.CommaText);
  // a,b,c,ca,d

  s.Free;
end.