Ver Mensaje Individual
  #3  
Antiguo 21-04-2014
Avatar de ZayDun
ZayDun ZayDun is offline
Miembro
 
Registrado: mar 2007
Posts: 129
Reputación: 18
ZayDun Va por buen camino
Cita:
Empezado por ecfisa Ver Mensaje
Hola ZayDun.

Código Delphi [-]
procedure SortByUserName(TS: TStrings);
  function CompareNom(TS: TStrings; const i1, i2: Integer): Integer;
  begin
    Result:= CompareText(Copy(TS[i1],4,MaxInt), Copy(TS[i2],4,MaxInt));
  end;
var
  SL: TStringList;
begin
  SL:= TStringList.Create;
  try
    SL.Assign(TS);
    SL.CustomSort(@CompareNom);
    TS.Assign(SL);
  finally
    SL.Free;
  end;
end;

Uso:
Código Delphi [-]
  SortByUserName(ListBox1.Items);

Saludos

Muchas gracias por tu ayuda ecfisa, me ordena perfectamente por usuario pero el numero principal no se ordena, queda así..

Código:
009 UsuarioA
005 UsuarioA
002 UsuarioB
006 UsuarioC
002 UsuarioC
Responder Con Cita