我需要对记录文件进行排序,但我不太确定该怎么做。我有一个记录文件,我尝试使用简单的冒泡排序对它们进行排序,但我被卡住了,需要一些帮助。有人可以帮我吗?我将在下面列出代码。
HighScoreFile = file of HighScoreRecord;
var
frmEnterDetails: TfrmEnterDetails;
HighScoreMasterFile: HighScoreFile;
HighScore:HighScoreRecord;
FileArray:array[1..20] of HighScoreRecord;
i:integer;
Procedure Sort
var
i,j,temp:integer;
AssignFile(HighScoreMasterFile, 'HighScores.dat');
Reset(HighScoreMasterFile);
while not eof(HighScoreMasterFile) do
begin
i:=i+1;
read(HighScoreMasterFile, HighScore);
FileArray[i].Name:=HighScore.Name;
FileArray[i].Date:=HighScore.Date;
FileArray[i].FinalScore:=HighScore.FinalScore;
for i:=0 19 do
for j:=0 to 18 do
if FileArray[j].Score > FileArray[j+1].Score then
begin
FileArray[temp]:=FileArray[j];
FileArray[j]:=FileArray[j+1];
FileArray[j+1]:=FileArray[temp];
end;
end;
任何帮助都会很棒。