Autor Beitrag
Kostas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Sa 05.06.10 23:26 
Hallo Zusammen,

Ich habe ein Record mit Adressen.
In einem dynamischen Array mehrere dieser Adressen angelegt.
Wie kann ich bitte nun das Array sortieren nach Nachname und Vorname?
Wie ich nach einem Element sortieren kann ist soweit klar.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure Sortieren(var AdressArray: array of TAdress);
var
  i, j: Integer;
  tmp: TAdress;
begin
  for i:= 1 to high(AdressArray) do
  begin
    j:= i;
    tmp := AdressArray[i];
    while (j > 0and (AdressArray[j-1].Vorname > tmp.Vorname) do
    begin
      AdressArray[j]:= AdressArray[j-1];
      Dec(j);
    end;
    AdressArray[j]:= tmp;
  end;
end;

Danke schon mal für die Hilfe
Gruß Kostas
Tryer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 226
Erhaltene Danke: 7



BeitragVerfasst: So 06.06.10 00:33 
Du must halt auch tauschen wenn der Vorname gleich ist und tmp.Nachname größer.

Grüsse, Dirk
Kostas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: So 06.06.10 00:39 
user profile iconTryer hat folgendes geschrieben Zum zitierten Posting springen:
Du must halt auch tauschen wenn der Vorname gleich ist und tmp.Nachname größer.

Grüsse, Dirk


oh je, hab einfach nur zu kompliziert gedacht. Sorry für die blöde Frage.

Gruß Kostas