Sorting algorithms/Shell sort: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added whitespace, changed some comments.)
m (→‎{{header|REXX}}: changed a variable name, changed DO-end comments.)
Line 2,789: Line 2,789:
return
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
shellSort: procedure expose @.; parse arg N /*obtain the N from the argument list*/
shellSort: procedure expose @.; parse arg n /*obtain the n from the argument list*/
i= N % 2 /*% is integer division in REXX. */
i= n % 2 /*% is integer division in REXX. */
do while i\==0
do while i\==0
do j=i+1 to N; k= j; p= k-i /*P: previous item*/
do j=i+1 to n; k= j; p= k - i /*P: previous item*/
_= @.j
_= @.j
do while k>=i+1 & @.p>_; @.k= @.p; k= k-i; p= k-i
do while k>=i+1 & @.p>_; @.k= @.p; k= k-i; p= k-i
end /*while k≥i+1*/
end /*while*/
@.k= _
@.k= _
end /*j*/
end /*j*/
if i==2 then i= 1
if i==2 then i= 1
else i= i * 5 % 11
else i= i * 5 % 11
end /*while i¬==0*/
end /*while*/
return
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/