Tuples sort lexicographically, so you can just use a custom "by"
transformation that puts the columns in the order you want:
sortrows(A, by=x->(x[3],x[1],x[2]))
On Friday, December 4, 2015 at 8:24:30 AM UTC-5, Ravi S wrote:
>
> Something like this?
>
> x = [ 2 0 "D"
> 1 -1 "A"
> 5 3 "B"
> 1 1 "A"
> 6 3 "C"]
>
> julia> x2=x[sortperm(x[:,2]),:]
> 5x3 Array{Any,2}:
> 1 -1 "A"
> 2 0 "D"
> 1 1 "A"
> 5 3 "B"
> 6 3 "C"
>
> julia> x1=x2[sortperm(x2[:,1]),:]
> 5x3 Array{Any,2}:
> 1 -1 "A"
> 1 1 "A"
> 2 0 "D"
> 5 3 "B"
> 6 3 "C"
>
> x3=x1[sortperm(x1[:,3]),:]
> 5x3 Array{Any,2}:
> 1 -1 "A"
> 1 1 "A"
> 5 3 "B"
> 6 3 "C"
> 2 0 "D"
>
> Regards,
> Ravi
>
> On Friday, December 4, 2015 at 3:02:05 PM UTC+5:30, user00 wrote:
>>
>> I am sorry if this question is asked before, but I couldn't find any
>> relevant discussion.
>>
>> I have an array 400x3 Array{Any,2} . First two columns consist of
>> numbers, and third column consists of strings. I want to first sort this
>> array with respect to third column and then with respect to first column
>> and then with respect to second column. The final result should be like:
>>
>> 1 -1 "A"
>> 1 1 "A"
>> 2 0 "A"
>> 5 3 "B"
>> 6 3 "C"
>>
>> Thanks.
>>
>