I have the following two dimensional Array:
[120 320;
150 270;
230 250]
the rows of which I want to sort with regards to the second element in each row. I could not find anyway to do that using Julia's Base.sort(). Is it is possible to achieve this using Base.sort() or are there any alternatives?
you can use sortslices for this:
julia> x = [120 320;
150 270;
230 250]
3×2 Array{Int64,2}:
120 320
150 270
230 250
julia> sortslices(x, dims=1, by= x->x[2])
3×2 Array{Int64,2}:
230 250
150 270
120 320
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With