Najprościej to będzie zrobić chyba tak. Wprawdzie Misiekd mnie ubiegł z odpowiedzą, ale ten mój przykład powinien rozwiać wszelkie ewentualne wątpliwości początkującego.
function SortujRosnaco(List : TStringList; Index1, Index2 : Integer) : Integer;
var
I1, I2 : integer;
begin
if (TryStrToInt(List[Index1], I1)) and TryStrToInt(List[Index2], I2) then
begin
if I1 < I2 then
Result := -1
else
if I1 > I2 then
Result := 1
else
Result := 0;
end
else
begin
Result := AnsiCompareText(List[Index1], List[Index2]);
end;
end;
procedure TForm1.Button1Click(Sender : TObject);
var
SL : TStringList;
begin
SL := TStringList.Create;
try
Listbox1.Sorted := False;
SL.Assign(Listbox1.Items);
SL.CustomSort(SortujRosnaco);
Listbox1.Items.Assign(SL);
finally
SL.Free
end;
end;