# Re: qsort

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Aug 08 2013 - 17:20:27 MDT

Yes ... if multidimensional arrays maybe

On 8/8/13 5:01 PM, David Brown wrote:
> I think dim_pqsort is what you want:
>
> ncl 0> a = (/1,2,3/)
> ncl 1> b = (/8,3,7/)
> ncl 2> ib = dim_pqsort(b,2)
> ncl 3> print(b)
>
>
> Variable: b
> Type: integer
> Total Size: 12 bytes
> 3 values
> Number of Dimensions: 1
> Dimensions and sizes: [3]
> Coordinates:
> (0) 3
> (1) 7
> (2) 8
> ncl 4> a = a(ib)
> ncl 5> print(a)
>
>
> Variable: a
> Type: integer
> Total Size: 12 bytes
> 3 values
> Number of Dimensions: 1
> Dimensions and sizes: [3]
> Coordinates:
> (0) 2
> (1) 3
> (2) 1
>
>
> -dave
>
> On Aug 8, 2013, at 4:44 PM, Marston Johnston <shejo284@gmail.com> wrote:
>
>> Hi,
>>
>> I would like to use the function "qsort" to sort one array and then sort several other arrays based on how the first array was sorted. Here is the idea:
>>
>> a = (/1,2,3/)
>> b = (/8,3,7/)
>> qsort(b)
>> print(b)
>>> 3,7,8
>> ...
>> is there a way to save the indices of the sorted b to then sort a such that:
>> print(a)
>>> 2,3,1
>>
>> Appreciate any help with this.
>> /M
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 8 17:20:23 2013

This archive was generated by hypermail 2.1.8 : Wed Aug 14 2013 - 18:35:09 MDT