Sorting algorithms/Cycle sort: Difference between revisions

Content added Content deleted
m (→‎version 4: changed alignment of a couple of comments.)
Line 1,467: Line 1,467:
end /*while p\==c*/
end /*while p\==c*/
end /*c*/
end /*c*/
/* [↓] display the sorted list. */
/* [↓] display the sorted list to term*/
_=@.1; do j=2 to #; _=_ @.j; end; say ' sorted list: ' _
_=@.1; do j=2 to #; _=_ @.j; end; say ' sorted list: ' _
return w /* [↓] find where to put X into @*/
return w /* [↓] find where to put X into @ */
.swap: do p=p while x==@.p; end; parse value @.p x with x @.p; w=w+1; return</lang>
.swap: do p=p while x==@.p; end; parse value @.p x with x @.p; w=w+1; return</lang>
'''output''' &nbsp; is identical to the 2<sup>nd</sup> version.
'''output''' &nbsp; is identical to the 2<sup>nd</sup> version.