[MATRIX-SIG] cmp?

Aaron Watters arw@dante.mh.lucent.com
Mon, 16 Jun 1997 17:13:16 -0400


I'm certain there are good reasons
why array cmp works the way it does,
please educate me.

>>> cmp(xx[0],xx[1])
-1
>>> cmp(xx[1],xx[0])
-1
>>> xx
array([[1, 1, 1, 0, 0, 0, 2, 2, 2],
       [1, 2, 3, 1, 2, 3, 1, 2, 3]])

what's the rationale here?  I want to sort arrays.
If I must write my own cmp function, it'll be really
really slow.

Also

>>> sort(xx)
array([[0, 0, 0, 1, 1, 1, 2, 2, 2],
       [1, 1, 1, 2, 2, 2, 3, 3, 3]])

Each sub array is sorted individually.  It seems
to me this should be written

array(map(sort, xx))

and in the former the subarrays should be sorted 
lexicographically as Python sorts tuples and lists.

Please explain. I'm missing something here.
Sorry if I'm being stupid again.

Thanks, Aaron Watters

ps: the motivation is, for fun, I'm trying
 to implement some database style functionality
 with the help of Numeric, heading towards
 accounting-type applications.

_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________