Swap cols/rows of a matrix

You don’t need the temporary variable:

function _swapcol!(x,i,j)
    for k in axes(x, 1)  # <- give dimension as input to axes function
        x[k, i], x[k, j] = x[k, j], x[k, i]
    end
end

If you are reshuffling the columns (or rows) you can supply a vector of indices:

julia> x = collect(reshape(1:12, 3, 4))
3×4 Array{Int64,2}:
 1  4  7  10
 2  5  8  11
 3  6  9  12

julia> x[:, [2,3,1,4]]
3×4 Array{Int64,2}:
 4  7  1  10
 5  8  2  11
 6  9  3  12