If anyone comes across an "exchange" sort I believe it's faster than a bubble sort. Here's what I have and it's working ok for this stage of the project. Actually I have more but it's proprietary so I cut it. If this gets anyones attention PM me.
{114 predict ****** v0.01} {right click chart, format window, properties, bars to right=2}
var: ui(0), di(0), k(0), j(0); array: uRoc[9999,0](0), dRoc[9999,0](0), uSort[3](0), dSort[3](0);
if ui>=3 and di>=3 then begin uSort[0]=uRoc[ui,0]; {populate uSort} uSort[1]=uRoc[ui-1,0]; uSort[2]=uRoc[ui-2,0]; uSort[3]=uRoc[ui-3,0]; dSort[0]=dRoc[di,0]; {populate dSort} dSort[1]=dRoc[di-1,0]; dSort[2]=dRoc[di-2,0]; dSort[3]=dRoc[di-3,0]; end;
for K = 0 to 3 begin {sort uSort} for J = K + 1 to 3 begin if uSort[J] < uSort[K] then begin Value1 = uSort[K]; uSort[K] = uSort[J]; uSort[J] = Value1; end; end; end; for K = 0 to 3 begin {sort dSort} for J = K + 1 to 3 begin if dSort[J] < dSort[K] then begin Value1 = dSort[K]; dSort[K] = dSort[J]; dSort[J] = Value1; end; end; end; |