Re: qsort

From: Marston Johnston <shejo284_at_nyahnyahspammersnyahnyah>
Date: Thu Aug 08 2013 - 17:40:04 MDT

Thanks guys,

These are the functions that I need.

/M

On Fri, Aug 9, 2013 at 1:01 AM, David Brown <dbrown@ucar.edu> 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
>
>
>

-- 
Only the fruitful thing is true!

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 8 17:40:23 2013

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