Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi array mit records sortieren (https://www.delphipraxis.net/10346-array-mit-records-sortieren.html)

.morpheus 16. Okt 2003 14:58


array mit records sortieren
 
hallo freunde!

ich habe eine reccord namens mannschaften und nöchti dies nach pkt sortieren


Delphi-Quellcode:
for i := 1 to 7 do
       begin
        if mannschaft[i].pkt > mannschaft[(i+1)].pkt then
          begin
            Hilfe := mannschaft[i];
            mannschaft[i] := mannschaft[i+1];
            mannschaft[(i+1)] := Hilfe;
          end;

so habe ich es probier doch da kam immer eine Zugriffsverletzung

kann mier jemand helfen??????????

bitte ich bin am verzweifeln

thx morepheus

sakura 16. Okt 2003 15:01

Re: array mit records sortieren
 
für kleine Datenmengen wäre der Bubblesort geeignet:

Delphi-Quellcode:
  for i := Low(mannschaft) to Pred(High(mannschaft)) do
    for j := Succ(i) to High(mannschaft) do
      if mannschaft[i].pkt > mannschaft[j].pkt then
      begin
        Hilfe := mannschaft[i];
        mannschaft[i] := mannschaft[j];
        mannschaft[j] := Hilfe;
      end;
...:cat:...


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:04 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz