Organize code in sort.jl