[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Array Sorting



PureBytes Links

Trading Reference Links

At 3:05 PM -0400 5/25/98, Val Clancy wrote:

>
>I am writing some code trying to sort a multidimentional array.
>Though someone would help with already existing efficient algorithms.
>

<snip>

>Can anyone help a bit here?
>This array then will be used for statistical  analysis of the value
>in Excel or Matlab ( min, max, mean, median, std, etc. ).
>
>Any code examples would be appreciated.
>


Attached is EasyLanguage code for a very fast sort routine. This code is an
indicator that test the sort code so you should be able to extract the code
that actually does the sort.

I use it all the time. (I think I got the algorithm from Bob Brickey of
Scientific Approaches but I have forgotten.)

Bob Fulks



Input:    Max(100);
Vars:     K(0), J(0);
Array:    Arr[100](0);

if Date > 970901 then Print("1  ", Date:6:0, CurrentBar:5:0, K:3:0,
   Arr[K]:5:2);

if Date = 970908 then begin
  for K = 1 to Max begin
     Arr[K] = Close[K];
     Print("2  ", Date:6:0, CurrentBar:5:0, K:3:0, Arr[K]:5:2);
  end;
  K = 0;
end;

if LastBarOnChart then begin

  for K = 1 to Max - 1 begin
     for J = K + 1 to Max begin
       if Arr[J] < Arr[K] then begin
          Value1 = Arr[K];
          Arr[K] = Arr[J];
          Arr[J] = Value1;
          Print(K:3:0, J:3:0, Arr[K]:5:2, Arr[J]:5:2);
       end;
     end;
  end;

  for K = 1 to Max begin
     Print("3  ", Date:6:0, CurrentBar:5:0, K:3:0, Arr[K]:5:2);
  end;

end;

Plot1(0,"Plot1");