def ranking(R):
    l = sorted(list(enumerate(R)), cmp=lambda a, b: cmp(a[1], b[1]))
    l = sorted(list(enumerate(l)), cmp=lambda a, b: cmp(a[1], b[1]))
    return array([kv[0] for kv in l])
Produces a linear ranking of the values in R.
dataset/ETHPy150Open pybrain/pybrain/pybrain/tools/functions.py/ranking