[Numpy-discussion] Sorting objects with ndarrays

Gael Varoquaux gael.varoquaux@normalesup....
Sun Feb 28 03:25:24 CST 2010


Hi,

I need to have list of objects that contain ndarrays to be sorted. The
reason that I want them sorted is that these list are populated in an
arbitrary order, but there order really doesn't matter, and I am trying
to make it reproducible for debugging and hashing.

The problem is that ndarrays cannot be compared. So I have tried to
override the 'cmp' in the 'sorted' function, however I am comparing
fairly complex objects, and I am having a hard time predicting wich
member of the object will contain the array. So I am building a more and
more complex 'cmp' replacement.

Does anybody has a good idea what a better strategy would be?

Cheers,

Gaël


More information about the NumPy-Discussion mailing list