Jump to content

Sorting algorithms/Cocktail sort: Difference between revisions

m
→‎{{header|REXX}}: changed wording in the section headers.
m (→‎{{header|REXX}}: elided the 3rd example.)
m (→‎{{header|REXX}}: changed wording in the section headers.)
Line 2,728:
=={{header|REXX}}==
===version handles blanks===
This REXX version can handle an 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,*/
/* bidirectional bubble sort, */
Line 2,832:
 
===version handles non-blanks===
This faster REXX version can handle an array elements that doesndon't contain blanks or spaces by using a simpler ''swap'' mechanism.
<lang rexx>/*──────────────────────────────────────────────────────────────────────────────────────*/
cocktailSort2: procedure expose @.; parse arg N; nn=n-1 /*N: the number of items in @.*/
Cookies help us deliver our services. By using our services, you agree to our use of cookies.