Ver Mensaje Individual
  #1  
Antiguo 21-03-2004
Avatar de Lepe
[Lepe] Lepe is offline
Miembro Premium
 
Registrado: may 2003
Posts: 7.424
Reputación: 29
Lepe Va por buen camino
TObjectList.Sort duda

Para el TObjectList, en la ayuda de delphi dice en el ejemplo del método Sort:
Cita:
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.
Código:
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;
Lo que está en rojo no debería ser "CompareNames" ¿?

Tal y como está no entiendo lo que hace, sin embargo, si fuese la direccion de la funcion CompareNames, si lo vería lógico.

Gracias Majo
Responder Con Cita