I am having trouble sorting a structured array - in the example below, sorting 
by the first column (col1) seems to work, but not sorting by the second column 
(col2). Is this a bug?

I am using numpy svn r8071 on MacOS 10.6.

Thanks for any help,

Thomas

Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> data = np.array([('a ', 2.), ('b', 4.), ('d', 3.), ('c', 1.)],
...                 dtype=[('col1', '|S5'), ('col2', '>f8')])
>>> 
>>> data
array([('a ', 2.0), ('b', 4.0), ('d', 3.0), ('c', 1.0)], 
      dtype=[('col1', '|S5'), ('col2', '>f8')])
>>> data.sort(order=['col1'])
>>> data
array([('a ', 2.0), ('b', 4.0), ('c', 1.0), ('d', 3.0)], 
      dtype=[('col1', '|S5'), ('col2', '>f8')])
>>> data.sort(order=['col2'])
>>> data
array([('a ', 2.0), ('d', 3.0), ('b', 4.0), ('c', 1.0)], 
      dtype=[('col1', '|S5'), ('col2', '>f8')])


_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to