[SciPy-user] bug in lexsort with two different dtypes?

Tom Denniston tom.denniston@alum.dartmouth....
Tue Jun 26 14:32:13 CDT 2007


In [1]: intArr1 = numpy.array([ 0, 1, 2,-2,-1, 5,-5,-5])
In [2]: intArr2 = numpy.array([1,1,1,2,2,2,3,4])
In [3]: charArr = numpy.array(['a','a','a','b','b','b','c','d'])

Here I sort two int arrays.  As expected intArr2 dominates intArr1 but
the items with the same intArr2 values are sorted forwards according
to intArr1
In [6]: numpy.lexsort((intArr1, intArr2))
Out[6]: array([0, 1, 2, 3, 4, 5, 6, 7])

This,  however, looks like a bug to me.  Here I sort an int array and
a str array.  As expected charArray dominates intArr1 but the items
with the same charArray values are sorted *backwards* according to
intArr1
In [5]: numpy.lexsort((intArr1, charArr))
Out[5]: array([2, 1, 0, 5, 4, 3, 6, 7])

Is this a bug or am I missing something?


--Tom


More information about the SciPy-user mailing list