{
Sort example
The following code sorts the objects in a list in alphabetical order based on their names. It assumes that the list contains only component references.
The CompareNames function performs the comparisons between objects in the list. The list is sorted when the user clicks a button.
} 
function CompareNames(Item1, Item2: Pointer): Integer;
begin
  Result := CompareText((Item1 as TComponent).Name, (Item2 as TComponent).Name);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  List1.Sort(@CompareText);
end; 
