How do you order events by block height and then transaction index?

lexsort returns indices for a multi-key ordering. The last supplied key is primary.

numpy.lexsort in practice

With heights [8,7,8] and positions [2,9,0], block seven comes first, then the two entries of block eight in position order. Separate chains when heights can overlap.

import numpy as np
np.lexsort(([2,9,0],[8,7,8]))

Result [1, 2, 0]

中文

怎样按区块高度再按交易序号排列事件?

lexsort 返回多键排序的索引,最后传入的键具有最高优先级。

numpy.lexsort 算例

区块高度 [8,7,8] 和块内序号 [2,9,0] 应先排 7 号块,再按序号处理 8 号块。多条链混合时还需区分链标识。

import numpy as np
np.lexsort(([2,9,0],[8,7,8]))

结果 [1, 2, 0]

References / 参考来源

Keep reading / 继续阅读