Board index » delphi » Sort Files

Sort Files

Hello !!!

How can I sort this type of file lets say by the "Code" field ?
Type
  MyRecord : Record of
                Code : Byte;
                Name : String;
             End;
Var
  MyFile : File of MyRecord;

Procedure SortMyFile;
Var
???
Begin
???
End;

Send the answer please to my E-Mail too (In the end of the message)

C'ya
Uri Hartmann
Caesarea, Israel.
`.,,.".,,.".,,.".,,.".,,.".,
This letter was sent by Uri Hartmann
from Caesarea, Israel.

Feel free to visit my HomePage:          
http://www.netvision.net.il/php/hartmann
`.,,.".,,.".,,.".,,.".,,.".,

 

Re:Sort Files


Hello !!!

What is the fastest way to sort for example this type of file by the
"Code" field ?

Type
  MyRecord : Record of
                Code : Byte;
                Name : String;
             End;
Var
  MyFile : File of MyRecord;

Procedure SortMyFile;
Var
???
Begin
???
End;

Send the answer please to my E-Mail too (In the end of the message)

C'ya
Uri Hartmann
Caesarea, Israel.
`.,,.".,,.".,,.".,,.".,,.".,
This letter was sent by Uri Hartmann
from Caesarea, Israel.

Feel free to visit my HomePage:          
http://www.netvision.net.il/php/hartmann
`.,,.".,,.".,,.".,,.".,,.".,

Re:Sort Files


In a message of 06 Aug 96 Uri Hartmann (hartm...@netvision.net.il) wrote:

 UH> From: Uri Hartmann <hartm...@netvision.net.il>

 UH> Hello !!!

 UH> What is the fastest way to sort for example this type of file by the
 UH> "Code" field ?

 UH> Type
 UH>   MyRecord : Record of
 UH>   Code : Byte;
 UH>   Name : String;
 UH>       End;
 UH> Var
 UH>   MyFile : File of MyRecord;

 UH> Procedure SortMyFile;
 UH> Var
 UH> ???
 UH> Begin
 UH> ???
 UH> End;

procedure SwapRecord(var one,two:MyRecord);
var temp:MyRecord;
begin
  temp:=one;
  one:=two;
  two:=temp;
end;

procedure SortMyFile;
var temp:byte;
begin
 temp:=0;
 repeat
   if myfile[temp].code>myfile[temp+1].code then
     swaprecord(myfile[temp],myfile[temp+1]);
   inc(temp);
 until temp=numrecords;
end;

Maybe doesn't work, but I guess you get the idea.

Rikard Bosnjakovic - N3 Power! (ri...@cure.ct.se)

.. If LBL is the answer, you must have asked the wrong question
.. If LBL is the answer, you must have asked the wrong questio

Other Threads