numpy structured array sorting by multiple columns
问题 A minimal numpy structured array generator: import numpy as np index = np.arange(4) A = np.stack((np.sin(index), np.cos(index)),axis=1) B = np.eye(4).astype(int) C = np.array([1, 0, 1, 0], dtype=bool) goodies = [(a, b, c, d) for a, b, c, d in zip(index, A, B, C)] dt = [('index', 'int'), ('two_floats', 'float', 2), ('four_ints', 'int', 4), ('and_a_bool', 'bool')] s = np.array(goodies, dtype=dt) generates the minimal numpy structured array: array([(0, [ 0. , 1. ], [1, 0, 0, 0], True), (1, [ 0