Albert Strasheim wrote:
> Hello all
>
> I'm trying to sort an array with two fields, but I'm getting a result that
> doesn't seem to make sense.
>
> What I tried (first attempt): I have two 2-D arrays. I would like to sort
> one based on the sort of the other. I managed to do this with argsort.
> However, the fancy indexing required to get the sorted array using what
> argsort returned was very slow. I followed this example:
>
> http://www.scipy.org/Numpy_Example_List#head-9f8656795227e3c43e849c6c0435eee
> b32afd722
>
> What I tried (second attempt): I created an array with two fields. I
> think/hope/expected that sorting the array would sort it on the first field
> in the dtype and then on the second. This is *much* faster than the fancy
> indexing approach.
>   

O.K.  I lied,

I realized that my comments in the VOID_compare code were silly (about 
being unable to define > or <).  It makes sense to just define them 
based on the first field, then the second field (if the first field is 
equal), and so forth.   Obviously this is not the only way one could 
define sorting (any field could be used as "the first field", and so forth.

But, is is a fairly obvious default to use the first field.  

It turns out, it was not so difficult to implement this and is now in SVN.

So, the VOID_compare now does something a little more intelligent when 
fields are defined which means that record arrays can now be 
lexicographically sorted more easily than using lexsort and take (as 
long as the fields are ordered according to how you want the sort to 
proceed).

-Travis


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to