
(*
 Delphi Object and Component Reference
# {bmc bm10.BMP} Sorted example
This example uses an edit box, a list box, and two buttons on a form. The buttons are named Add and Sort. When the user clicks the Add button, the text in the edit box is added to the list in the list box. Before the user clicks the sort button, any new items are added to the end of the list.  After the user clicks the Sort button, the list in the list box is sorted and remains sorted, even if additional strings are added.  If the user clicks the sort button again, the list box remains sorted, but any new strings are again added to the end of the list.
*) 
procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox1.Items.Add('Not');
  Listbox1.Items.Add('In');
  ListBox1.Items.Add('Alphabetical');
  ListBox1.Items.Add('Order');
end;
procedure TForm1.AddClick(Sender: TObject);
begin
  ListBox1.Items.Add(Edit1.Text);
end;
procedure TForm1.SortClick(Sender: TObject);
begin
  ListBox1.Sorted := not ListBox1.Sorted;
end; 
