delphi - sorting a file of records error -


i need sort file of records not quite sure of how it. have file of records , have attempted sort them using simple bubble sort stuck , need help. me? list code below.

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) begin       i:=i+1;   read(highscoremasterfile, highscore);   filearray[i].name:=highscore.name;   filearray[i].date:=highscore.date;   filearray[i].finalscore:=highscore.finalscore;    i:=0 19     j:=0 18       if filearray[j].score > filearray[j+1].score         begin           filearray[temp]:=filearray[j];           filearray[j]:=filearray[j+1];           filearray[j+1]:=filearray[temp];        end; end; 

any great.

it possible not correct 100%, haven't test in ide. can use debugger in order see how algorithm working step step. link explain how bubble sort working http://delphi.wikia.com/wiki/bubble_sort.

    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;     begin     assignfile(highscoremasterfile, 'highscores.dat');     reset(highscoremasterfile);     := 0;     while not eof(highscoremasterfile)     begin           i:=i+1;       read(highscoremasterfile, highscore);       filearray[i].name:=highscore.name;       filearray[i].date:=highscore.date;       filearray[i].finalscore:=highscore.finalscore;     end;        i:=1 19         j:=1 18           if filearray[i].score > filearray[j+1].score             begin               temp := i;               highscore := filearray[temp];               filearray[temp]:=filearray[j];               filearray[j]:=highscore;            end;   end; 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -