Hallo!
Ich habe folgendes Array
Delphi-Quelltext
1:
| BankSet: array of TBankData |
mit folgender Typdeklaration
Delphi-Quelltext
1: 2: 3: 4: 5: 6:
| type TBankData = record Number: Byte; Name: string; Position: Byte; end; |
Innerhalb des Programms soll das Array nun mehrmals umsortiert werden. Einmal nach BankNumber, ein anderes mal nach BankPosition oder Number. Bis jetzt habe ich dafür jedes mal eine eigene Sort-Prozedur geschrieben (bzw. nur abgeändert

).
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
| procedure BankPositionSort(var a: array of TBankData; Lo, Hi: integer); procedure QuickSort(l, r: integer); var i, j: integer; x: Byte; y: TBankData; begin i := l; j := r; x := a[(l+r) DIV 2].Position; repeat while a[i].Position < x do inc(i); while x < a[j].Position do dec(j); if i <= j then begin y := a[i]; a[i] := a[j]; a[j] := y; i := i + 1; j:=j-1; end; until i>j; if l < j then QuickSort(l, j); if i < r then QuickSort(i, r); end; begin QuickSort(Lo,Hi); end; |
Gibt es eine Möglichkeit, der Prozedur einen Parameter mitzugeben, der das entsprechende Record-Element aufnimmt? Etwa so:
Delphi-Quelltext
1: 2: 3:
| procedure BankPositionSort(var a: array of TBankData; Lo, Hi: integer; Element: string);
x := a[(l+r) DIV 2].Element^; |
Danke an Alle, die sich jetzt den Kopf zerbrechen.
Gruß
Christoph
P.S.: Bei dem kleinen record geht das mit den einzelnen Sort-Prozeduren noch, aber unter anderem habe ich auch ein Array of Record mit 9 Elementen. Da wird's dann schnell unübersichtlich.