Awkwardsaw
2013-07-23 19:56:17
I'm looking for a way to sort out a TExtendedArray. Through google I found this:
And all the other sources that i've seen match this algorithm. The problem is, it doesn't work :\
When I tried doing this:
I return with:
Help? :) I've never played with any sorting algos, so I really don't know what I'm doing :p
Procedure BubbleSort(var a:TExtendedArray; size:integer);
var
i,j : integer;
temp : extended;
begin
for i:=1 to size-1 do
for j:=1 to size do
if a[i]>a[j] then
begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
end;
end; And all the other sources that i've seen match this algorithm. The problem is, it doesn't work :\
When I tried doing this:
program new;
var
colors : TExtendedArray;
Procedure BubbleSort(var a:TExtendedArray; size:integer);
var
i,j : integer;
temp : extended;
begin
for i:=1 to size-1 do
for j:=1 to size do
if a[i]>a[j] then
begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
end;
end;
begin
Colors := [0.1, 0.5, 0.77, 0.6, 0.07];
BubbleSort(Colors, 4);
BubbleSort(Colors, 4);
BubbleSort(Colors, 4);// I decided to try sorting out multiple times, but it really doesnt do anything
BubbleSort(Colors, 4);
BubbleSort(Colors, 4);
writeln(Colors);
end.I return with:
[ 1.0000000000000000E-0001, 8.0000000000000000E-0001, 7.7000000000000000E-0001, 7.0000000000000000E-0002, 5.0000000000000000E-0001]Help? :) I've never played with any sorting algos, so I really don't know what I'm doing :p