Sorting algorithms/Cocktail sort: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: elided the 3rd example.)
m (→‎{{header|REXX}}: changed wording in the section headers.)
Line 2,728: Line 2,728:
=={{header|REXX}}==
=={{header|REXX}}==
===version handles blanks===
===version handles blanks===
This REXX version can handle an array that may contain blanks or spaces.
This REXX version can handle array elements that may contain blanks or spaces.
<lang rexx>/*REXX program sorts an array using the cocktail─sort method, A.K.A.: happy hour sort,*/
<lang rexx>/*REXX program sorts an array using the cocktail─sort method, A.K.A.: happy hour sort,*/
/* bidirectional bubble sort, */
/* bidirectional bubble sort, */
Line 2,832: Line 2,832:


===version handles non-blanks===
===version handles non-blanks===
This faster REXX version can handle an array that doesn't contain blanks or spaces by using a simpler ''swap'' mechanism.
This faster REXX version can handle array elements that don't contain blanks or spaces by using a simpler ''swap'' mechanism.
<lang rexx>/*──────────────────────────────────────────────────────────────────────────────────────*/
<lang rexx>/*──────────────────────────────────────────────────────────────────────────────────────*/
cocktailSort2: procedure expose @.; parse arg N; nn=n-1 /*N: the number of items in @.*/
cocktailSort2: procedure expose @.; parse arg N; nn=n-1 /*N: the number of items in @.*/