Delphi-Quellcode:
procedure TTerminKalender.Sort;
procedure Swap(AOne, ATwo: TTermin);
var
lTemp: TTermin;
begin
lTemp := TTermin.Create(0, 0,'');
try
lTemp.Time := AOne.Time;
lTemp.Text := AOne.Text;
AOne.Time := ATwo.Time;
AOne.Text := ATwo.Text;
ATwo.Time := lTemp.Time;
ATwo.Text := lTemp.Text;
finally
lTemp.Free;
end;
end;
var
i, j: Integer;
begin
for i := 0 to FTerminListe.Count - 1 do
for j := 0 to FTerminListe.Count - 2 do
if TimeToStr(TTermin(FTerminListe.Items[j]).Time) > TimeToStr(TTermin(FTerminListe.Items[j + 1]).Time) then
Swap(TTermin(FTerminListe.Items[j]), TTermin(FTerminListe.Items[j + 1]));
end;
Sieht nun so aus. Time ist vom Typ TDateTime.