Sorting algorithms/Bogosort: Difference between revisions

m
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
Line 3,075:
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">func in_order(a) {
return true if (a.len <= 1);
var first = a[0];
a.ftlast(-1).all { |elem| first <= elem  ? do { first = elem; true }  : false }
}
 
func bogosort(a) {
a.shuffle! while  !in_order(a);
return a;
}
 
var arr = 5.of { 100.rand.intirand };
say "Before: #{arr}";
say "After: #{bogosort(arr)}";</syntaxhighlight>
{{out}}
<pre>
2,747

edits