hey i am trying to sort a file of records by name. Im trying to use the bubble sort but all the code i ve found is with the use of arrays. Any idea pls.

Procedure Bubble_Sort;

var
a : array [1..20] of string;
i,j : integer;
t : string;

begin
clrscr;
create_client;
for i:= 1 to Filesize(C) do
Read(C,recc);
a:= recc.name;

for i := 1 to Filesize(C) do
for j := 1 to Filesize(C)-1 do

if a [j] > a[j+1] then
begin
t := a[j];
a[j] := a[j+1];
a[j+1] := t;
end;

writeln;
for i := 1 to filesize(C) do writeln(a);

readln;
end;

you are using i variable both in reading the file and in the first for cycle.

best regards,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.