def applySiiRanking(siiContainer, specfile):
    """Iterates over all Sii entries of a specfile in siiContainer and sorts Sii
    elements of the same spectrum according to the score attribute specified in
    ``siiContainer.info[specfile]['rankAttr']``. Sorted Sii elements are then
    ranked  according to their sorted position, if multiple Sii have the same
    score, all get the same rank and the next entries rank is its list position.

    :param siiContainer: instance of :class:`maspy.core.SiiContainer`
    :param specfile: unambiguous identifier of a ms-run file. Is also used as
        a reference to other MasPy file containers.
    """
    attr = siiContainer.info[specfile]['rankAttr']
    reverse = siiContainer.info[specfile]['rankLargerBetter']
    for itemList in listvalues(siiContainer.container[specfile]):
        sortList = [(getattr(sii, attr), sii) for sii in itemList]
        itemList = [sii for score, sii in sorted(sortList, reverse=reverse)]

        #Rank Sii according to their position
        lastValue = None
        for itemPosition, item in enumerate(itemList, 1):
            if getattr(item, attr) != lastValue:
                rank = itemPosition
            item.rank = rank
            lastValue = getattr(item, attr)