Skip to content

Instantly share code, notes, and snippets.

@digital-carver
Created June 30, 2022 12:51
Show Gist options
  • Save digital-carver/35730613c98d441629c3ba4b98b20758 to your computer and use it in GitHub Desktop.
Save digital-carver/35730613c98d441629c3ba4b98b20758 to your computer and use it in GitHub Desktop.
using BenchmarkTools
function bubble_sort(v::AbstractArray{T}) where T<:Real
for _ in 1:length(v)-1
for i in 1:length(v)-1
@inbounds if v[i] > v[i+1]
v[i], v[i+1] = v[i+1], v[i]
end
end
end
return v
end
let v = rand(Int32, 100_000)
@btime bubble_sort($v)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment