Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Stalin sort drill (probably the most useless sorting algorithm out there, but a fun exercise if you have 2-5 minutes to kill)
- function ssort(x::Array{<:Any, 1})
- n = length(x)
- y = similar(x)
- y[1] = x[1]
- c = 1
- for i = 2:n
- if x[i] >= y[c]
- c += 1
- y[c] = x[i]
- end
- end
- return y[1:c]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement