Let's try searching the PDL documentation with 'pdldoc -a' where '-a'
means 'search for this string':
bash$ pdldoc -a sort
init The init method initializes a new instance of INTERP.
It needs as input an interpolation type and two piddles
holding the x and y values to be interpolated. The GSL
routines require that x be monotonically increasing and
a quicksort is performed by default to ensure that. You
can skip the quicksort by passing the option {Sort =>
0}.
qsort Quicksort a vector into ascending order.
qsorti Quicksort a vector and return index of elements in
ascending order.
qsortvec Sort a list of vectors lexicographically.
qsortveci Sort a list of vectors lexicographically, returning the
indices of the sorted vectors rather than the sorted
list itself.
It looks as if you're after 'qsort', so let's try that:
Module PDL::Ufunc
qsort
Signature: (a(n); [o]b(n))
Quicksort a vector into ascending order.
print qsort random(10);
Bad values are moved to the end of the array:
pdl> p $b
[42 47 98 BAD 22 96 74 41 79 76 96 BAD 32 76 25 59 BAD 96 32 BAD]
pdl> p qsort($b)
[22 25 32 32 41 42 47 59 74 76 76 79 96 96 96 98 BAD BAD BAD BAD]
Cheers,
Matt
On Thu, Feb 2, 2012 at 8:09 AM, MARK BAKER <[email protected]> wrote:
>
>
> ________________________________
> From: MARK BAKER <[email protected]>
> To: "[email protected]" <[email protected]>
> Sent: Wednesday, February 1, 2012 10:43 PM
> Subject: how to sort a piddle ???
>
> I have been looking over PDL and trying to learn every thing inside and out
> and I came across this, how do I sort a piddle ???
> is there a special function for sorting a piddle
>
> I tried this it doesn't work ...
>
> pdl> @e = pdl(3,2,6,4,8,6);
> pdl> @r = sort{$a <=> $b} @e;
> pdl> p @r;
> [3 2 6 4 8 6]
> pdl> why didnt this sort ?
>
> Now I can think of about 6 different ways to sort this
> but they are tedious maybe someone can show me a simpler way !
>
> Thanks
>
> -Mark R Baker
> [email protected]
>
>
>
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
--
Matthew Kenworthy / Assistant Professor / Leiden Observatory
Niels Bohrweg 2 (#463) / P.O. Box 9513 / 2300 RA Leiden / NL
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl