Sorting algorithms/Cocktail sort: Difference between revisions

→‎version handles blanks: It is a Rexx idiom to use <stem>.0 to hold the number of items in numerically-suffixed stem arrays.
(Added Quackery.)
(→‎version handles blanks: It is a Rexx idiom to use <stem>.0 to hold the number of items in numerically-suffixed stem arrays.)
Line 3,661:
call show@ 'before sort' /*show unsorted array elements. */
say copies('█', 101) /*show a separator line (a fence). */
call cocktailSort # @.0 /*invoke the cocktail sort subroutine. */
call show@ ' after sort' /*show sorted array elements. */
exit /*stick a fork in it, we're all done. */
Line 3,702:
@.23='the world ◄─── XXI'
@.24='the fool [often unnumbered] ◄─── XXII'
return@.0 =24 /* [↑]number of adjustentries forin DOthe loop advancementarray. */
 
return
do #=1 until @.#==''; end; #= #-1 /*find how many entries in the array. */
return /* [↑] adjust for DO loop advancement.*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
show@: w= length(#); do j=1 for # /*#: is the number of items in @. */0)
do j=1 to @.0 /*@.0 is the number of items say 'element' right(j, w) arg(1)":" in @.j */
say 'element' right(j, w) arg(1)":" end /*@.j*/ /* ↑ */
returnend /*j*/ /* /* └─────max width of any line.*/</syntaxhighlight>
return /* └─────max width of any line.*/</syntaxhighlight>
{{out|output|text=&nbsp; when using the internal default inputs:}}