Comment ========================================================== QuickSort program written in MarxMenu. Works like DOS sort program. This shows parameter passing and recursive programming. Usage: DIR|MARXMENU SORT|MORE MARXMENU SORT INFILE OUTFILE ========================================================== EndComment ClearScreenOnExit Off var SortBuf Middle ReadTextFile (ParamStr(2),SortBuf) Sort(1,NumberOfElements(SortBuf)) WriteTextFile (ParamStr(3),SortBuf) Procedure Sort (L,R) var I,J I = L J = R Middle = SortBuf[(L+R)/2] repeat while SortBuf[I] < Middle I = I + 1 endwhile while Middle < SortBuf[J] J = J - 1 endwhile if I <= J Middle = SortBuf[J] SortBuf[J] = SortBuf[I] SortBuf[I] = Middle I = I + 1 J = J - 1 endif until I > J if (J - L) < (R - I) if L < J then Sort(L,J); if I < R then Sort(I,R); else if I < R then Sort(I,R); if L < J then Sort(L,J); endif EndProc