Skip to content

Commit 838ae9d

Browse files
berquistleios
authored andcommitted
Update Julia bogosort (#379)
- bug that caused sorting order to be reversed - spaces after commas - Julia v1 has shuffle! in the Random package
1 parent 0580b79 commit 838ae9d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

contents/bogo_sort/bogo_sort.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ In code, it looks something like this:
1414

1515
{% method %}
1616
{% sample lang="jl" %}
17-
[import:10-14, lang:"julia"](code/julia/bogo.jl)
17+
[import:12-16, lang:"julia"](code/julia/bogo.jl)
1818
{% sample lang="cs" %}
1919
[import:9-15, lang:"csharp"](code/csharp/BogoSort.cs)
2020
{% sample lang="clj" %}

contents/bogo_sort/code/julia/bogo.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
using Random
2+
13
function is_sorted(a::Vector{Float64})
24
for i = 1:length(a)-1
3-
if (a[i+1] > a[i])
5+
if (a[i] > a[i + 1])
46
return false
57
end
68
end
@@ -14,7 +16,7 @@ function bogo_sort(a::Vector{Float64})
1416
end
1517

1618
function main()
17-
a = [1., 3, 2,4]
19+
a = [1, 3, 2, 4]
1820
bogo_sort(a)
1921
println(a)
2022
end

0 commit comments

Comments
 (0)