couldn’t find similar posts, so posting my own question.
I got variable array of real:
price = array([58.9],[38.7],[8.95],[28.3])
I need to order it descending, with my code everything works well until last value of the array, I know even why, but can’t find solution on my own. Anyway here’s the code:
Procedure orderarray;
Var i,dz, j: Integer;
c :real;
v :string[25];
Begin
dz := 1;
For i := 1 to 3 do
Begin
For j:=i+1 to 4 do
if price[j]>price[dz] //searches for highest value in the array
then dz:=j;
c:=price[i]; price[i] := price[dz]; price[dz] := c; //switches current value with highest
End;
I’ve found solution to my own problem. Posting it just in case anyone will need it. I needed to reset dz to i, not j
Thank you everybody for your help, wouldn’t get to the solution without you, anyway.