Sorting algorithms/Strand sort: Difference between revisions

Content added Content deleted
m (→‎{{header|AppleScript}}: Made into an in-place sort and more efficient.)
(Added Quackery.)
Line 1,628: Line 1,628:
print strand_sort([1, 6, 3, 2, 1, 7, 5, 3])</syntaxhighlight>
print strand_sort([1, 6, 3, 2, 1, 7, 5, 3])</syntaxhighlight>
Output:<syntaxhighlight lang="text">[1, 1, 2, 3, 3, 5, 6, 7]</syntaxhighlight>
Output:<syntaxhighlight lang="text">[1, 1, 2, 3, 3, 5, 6, 7]</syntaxhighlight>

=={{header|Quackery}}==

<syntaxhighlight lang="Quackery"> [ [] temp put
[ dup [] != while
over [] != while
over 0 peek
over 0 peek
> not if dip
[ behead
temp take
swap join
temp put ]
again ]
join
temp take swap join ] is merge ( [ [ --> [ )

[ [] swap
1 split witheach
[ over -1 peek
over > iff
[ swap dip join ]
else join ] ] is unbraid ( [ --> [ [ )

[ [] swap
[ unbraid
rot merge swap
dup [] = until ]
drop ] is strandsort ( [ --> [ )

[] 25 times
[ 89 random 10 + join ]
say "Before: " dup echo cr
strandsort
say "After: " echo cr</syntaxhighlight>

{{out}}

<pre>Before: [ 46 66 79 51 21 79 65 46 95 17 92 13 32 11 72 44 83 64 50 88 46 38 57 37 27 ]
After: [ 11 13 17 21 27 32 37 38 44 46 46 46 50 51 57 64 65 66 72 79 79 83 88 92 95 ]</pre>


=={{header|Racket}}==
=={{header|Racket}}==