def getRL(args):
    """Get RL (ranking loss)
    examine each (0,1) pair's order in the sorted cols in prediction (by prob)

    Notice for 'sort by probability's adaptation in SNE:
        Example 0 1 | 1 0 0:
           (pos 0 1   2 3 4)
            we can assert at most:
            prob pos(1) >= prob pos(0)
            prob pos(2) >= prob pos(3)
            prob pos(2) >= prob pos(4)
        Since no further knowledge, so 'sort by prob' renders:
            (by stable sort)
            1 1 0 0 0
            1 2 0 3 4 (pos)
    """
    usr2NonzeroCols = args['usr2NonzeroCols']
    u2predictions = args['u2predictions']
    totalLabelsNum = args['totalLabelsNum']
    rlPairsCnt = args['rlPairsCnt']
    totalLoss = 0.0
    rlPairsCnt = float(rlPairsCnt)
    for usrid in u2predictions:
        bestCols = u2predictions[usrid]
        y_nonzeroCols = usr2NonzeroCols[usrid]
        y_zeroCols = range(totalLabelsNum)
        col2Val = map(lambda v: [v, 0], y_zeroCols)
        for v in y_nonzeroCols:
            y_zeroCols.remove(v)
        for v in bestCols:
            col2Val[v][1] = 1
        col2Val.sort(key=lambda v: v[1], reverse=True)
        col2Order = {}
        for ind, v in enumerate(col2Val):
            col2Order[v[0]] = ind
        errCnt = 0
        for col1 in y_zeroCols:
            for col2 in y_nonzeroCols:
                if col2Order[col1] < col2Order[col2]:
                    errCnt += 1
        lossPerUsr = errCnt / rlPairsCnt
        totalLoss += lossPerUsr
    return totalLoss / len(u2predictions)
