Mega Code Archive

 
Categories / Delphi / Examples
 

How to arrange a list alphabetically

Title: How to arrange a list alphabetically procedure TForm1.Button1Click(Sender: TObject); var i, x: Integer; begin for i := 0 to (ListBox1.Items.Count - 1) do for x := 0 to (ListBox1.Items.Count - 1) do if (ListBox1.Items[x] .Items[i]) and (x i) then begin ListBox1.Items.Insert(i, ListBox1.Items[x]); ListBox1.Items.Delete(x + 1); end; end;