Sorting algorithms/Quicksort: Difference between revisions

Content added Content deleted
m (→‎version 1: added wording to the REXX version section header.)
m (→‎{{header|REXX}}: added a comment to the REXX section header.)
Line 6,182: Line 6,182:
===version 1===
===version 1===
This REXX version doesn't use or modify the program stack.
This REXX version doesn't use or modify the program stack.

It is over &nbsp; '''400%''' &nbsp; times faster then the 2<sup>nd</sup> REXX version &nbsp; (using the exact same random numbers).

<lang rexx>/*REXX program sorts a stemmed array using the quicksort algorithm. */
<lang rexx>/*REXX program sorts a stemmed array using the quicksort algorithm. */
call gen@ /*generate the elements for the array. */
call gen@ /*generate the elements for the array. */
Line 6,421: Line 6,424:
{{trans|Python}}The Python code translates very well to [[ooRexx]] but here is a way to implement it in classic REXX as well.
{{trans|Python}}The Python code translates very well to [[ooRexx]] but here is a way to implement it in classic REXX as well.


This REXX version doesn't handle numbers with leading/trailing/embedded blanks, or textual values that have blanks (or whitespace) in them.
<lang Rexx> a = '4 65 2 -31 0 99 83 782 1'
<lang Rexx>
/*REXX*/
a = '4 65 2 -31 0 99 83 782 1'
do i = 1 to words(a)
do i = 1 to words(a)
queue word(a, i)
queue word(a, i)