Sorting algorithms/Bogosort: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Minor tidy) |
(Added Easylang) |
||
Line 1,185: | Line 1,185: | ||
} |
} |
||
}</syntaxhighlight> |
}</syntaxhighlight> |
||
=={{header|EasyLang}}== |
|||
<syntaxhighlight> |
|||
proc shuffle . l[] . |
|||
for i = len l[] downto 2 |
|||
r = randint i |
|||
swap l[i] l[r] |
|||
. |
|||
. |
|||
proc issorted . l[] r . |
|||
for i = 2 to len l[] |
|||
if l[i] < l[i - 1] |
|||
r = 0 |
|||
return |
|||
. |
|||
. |
|||
r = 1 |
|||
. |
|||
proc bogosort . l[] . |
|||
repeat |
|||
issorted l[] r |
|||
until r = 1 |
|||
shuffle l[] |
|||
. |
|||
. |
|||
list[] = [ 2 7 41 11 3 1 6 5 8 ] |
|||
bogosort list[] |
|||
print list[] |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
[ 1 2 3 5 6 7 8 11 41 ] |
|||
</pre> |
|||
=={{header|Eiffel}}== |
=={{header|Eiffel}}== |