def METHOD_NAME(acks):
    names = []
    for email, D in acks.items():
        L = D.items()
        L.sort()
        prefname = L[0][1]
        for file, name in L[1:]:
            prefname = prefname or name
        names.append(prefname or email)
    def f(s1, s2):
        s1 = s1.lower()
        s2 = s2.lower()
        return cmp((s1.split()[-1], s1),
                   (s2.split()[-1], s2))
    names.sort(f)
    for name in names:
        print name