def argsortBigToSmallByTiers(tierAScores, tierBScores):
''' Perform argsort, prioritizing first arr then second arr.
Example
-------
>>> AScores = [1, 1, 1, 0, 0]
>>> BScores = [6, 5, 4, 8, 7]
>>> print argsortBigToSmallByTiers(AScores, BScores)
[0 1 2 3 4]
>>> AScores = [1, 1, 1, 0, 0, -1, -1, -1]
>>> BScores = [6, 5, 4, 8, 7, 11, 1.5, -1.5]
>>> print argsortBigToSmallByTiers(AScores, BScores)
[0 1 2 3 4 5 6 7]
>>> print argsortBigToSmallByTiers(BScores, AScores)
[5 3 4 0 1 2 6 7]
'''
tierAScores = np.asarray(tierAScores, dtype=np.float64)
sortids = argsort_bigtosmall_stable(tierAScores)
limits = np.flatnonzero(np.diff(tierAScores[sortids]) != 0) + 1
sortids = sortids[
argsort_bigtosmall_stable(tierBScores, limits=limits)]
return sortids
评论列表
文章目录