def dnfcode_key(code):
    """Return a rank/dnf code sorting key."""
    # rank [rel] '' dsq hd|otl dnf dns
    dnfordmap = {
                 u'rel':8000,
                 u'':8500,
                 u'hd':8800,u'otl':8800,
                 u'dnf':9000,
                 u'dns':9500,
                 u'dsq':10000,}
    ret = 0
    if code is not None:
        code = code.lower()
        if code in dnfordmap:
            ret = dnfordmap[code]
        else:
            code = code.strip(u'.')
            if code.isdigit():
                ret = int(code)
    return ret