Sorting algorithms/Insertion sort: Difference between revisions

m
→‎{{header|REXX}}: shorten a long literal by one byte, changed a variable name, made a variable global.
m (→‎{{header|REXX}}: changed some comments, variable names, and some alignments.)
m (→‎{{header|REXX}}: shorten a long literal by one byte, changed a variable name, made a variable global.)
Line 1,730:
/*──────────────────────────────────GEN@ subroutine─────────────────────*/
gen@: @.= /*assign default value to array. */
@.1 = "---Monday's Child Is Fair of Face (by Mother Goose)---"
@.2 = "Monday's child is fair of face;"
@.3 = "Tuesday's child is full of grace;"
Line 1,741:
do #=1 while @.# \=='' /*find how many entries in array.*/
end /*short and sweet DO loop, eh? */
#@.0=#-1 /*because of DO, adjust highItem.high item*/
return
/*──────────────────────────────────INSERTIONSORT subroutine────────────*/
insertionSort: procedure expose @.; parse arg highItem
do i=2 to highItem; value=@.i0
value=@.i; do j=i-1 by -1 while j\==0 & @.j>value
jp=j+1; @.jp=@.j
end /*j*/
Line 1,762:
{{out}}
<pre>
element 1 before sort: ---Monday's Child Is Fair of Face (by Mother Goose)---
element 2 before sort: Monday's child is fair of face;
element 3 before sort: Tuesday's child is full of grace;
Line 1,772:
element 9 before sort: Is blithe and bonny, good and gay.
───────────────────────────────────────────────────────────────────────────────
element 1 after sort: ---Monday's Child Is Fair of Face (by Mother Goose)---
element 2 after sort: But the child that is born on the Sabbath day
element 3 after sort: Friday's child is loving and giving;