Reputation: 253
I am working with a matrix that looks like this in Julia:
1-element Array{Array{Array{Int64,2},1},1}:
Array{Int64,2}[[14 32; 32 77]]
I want to sort the matrix in decreasing order just as I did in R with an output that looks like this:
[1] 77 32 32 14
I tried using this function in Julia:
[sort(z, rev=true)]
but I get the same matrix I started with, unsorted. Is it possible to sort a matrix in Julia so that it has a 1D output like in R?
Upvotes: 2
Views: 273
Reputation: 10982
In the same spirit:
m=[[14 32; 32 77]]
sort(collect(Iterators.flatten(m)), rev=true)
Output:
4-element Array{Int64,1}:
77
32
32
14
Upvotes: 3
Reputation: 160
Do you mean something like this
m = [[14 32; 32 77]]
sort(hcat(m...)[:], rev=true)
Upvotes: 0