# [ncl-talk] mistake in the documentation of dim_pqsort_n function

Mary Haley haley at ucar.edu
Mon Jul 23 14:15:46 MDT 2018

```dim_pqsort_n seems to be working fine for me. You have to make sure that
when you are testing this, you pass in the original x array, and not the x
array that might have been sorted by a previous call to dim_pqsort_n.

It would help if you provide an example. Here's one I used:

xo_n2 =  (/6,3,1,2,5,4/)
xo_n1 =  (/6,3,1,2,5,4/)
xo_p1 =  (/6,3,1,2,5,4/)
xo_p2 =  (/6,3,1,2,5,4/)

in_n2 = dim_pqsort_n(xo_n2,-2,0)
in_n1 = dim_pqsort_n(xo_n1,-1,0)
in_p1 = dim_pqsort_n(xo_p1, 1,0)
in_p2 = dim_pqsort_n(xo_p2, 2,0)

print("Option -2: Sort xo_n2 in decreasing order")
print("xo_n2 = " + str_join(""+xo_n2,","))
print("in_n2 = " + str_join(""+in_n2,","))

print("Option -1: Sort xo_n1 in decreasing order, but don't touch original
xo_n1")
print("xo_n1 = " + str_join(""+xo_n1,","))
print("in_n1 = " + str_join(""+in_n1,","))

print("Option  1: Sort xo_p1 in increasing order, but don't touch original
xo_p1")
print("xo_p1 = " + str_join(""+xo_p1,","))
print("in_p1 = " + str_join(""+in_p1,","))

print("Option  2: Sort xo_p2 in increasing order")
print("xo_p2 = " + str_join(""+xo_p2,","))
print("in_p2 = " + str_join(""+in_p2,","))

And here's the output:

Option -2: Sort xo_n2 in decreasing order
xo_n2 = 6,5,4,3,2,1
in_n2 = 0,4,5,1,3,2

Option -1: Sort xo_n1 in decreasing order, but don't touch original xo_n1
xo_n1 = 6,3,1,2,5,4
in_n1 = 0,4,5,1,3,2

Option  1: Sort xo_p1 in increasing order, but don't touch original xo_p1
xo_p1 = 6,3,1,2,5,4
in_p1 = 2,3,1,5,4,0

Option  2: Sort xo_p2 in increasing order
xo_p2 = 1,2,3,4,5,6
in_p2 = 2,3,1,5,4,0

--Mary

On Thu, Jul 19, 2018 at 7:19 AM, Beáta Szabó-Takács <szabo.b at czechglobe.cz>
wrote:

> Dear NCL Users,
>
> I would like to inform you that I found a mistake in the documentation of
> dim_pqsort_n function https://www.ncl.ucar.edu/
> Document/Functions/Built-in/dim_pqsort_n.shtml
>
>
>
> I found that the kflag ( 1 and 2) behave opposite as in the documentation.
> I mean if I used kflag 2 the x was not sorted and when I used kflag 1 the x
> was also sorted.
>
>
>
> Best regards,
>
> Beata
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180723/2cce3b19/attachment.html>
```