def prevLexPermutation(s):
    """Given a string, return the previous lexicographic permutation"""
    """If the first permutation, return None"""
    l = [c for c in s]
    for i in range(len(l)-1, 0, -1):
        if(l[i-1] > l[i]):
            for j in range(len(l)-1, i-1, -1):
                if (l[j] < l[i-1]):
                    temp = l[j]
                    l[j] = l[i-1]
                    l[i-1] = temp
                    
                    end = l[i:]
                    end.reverse()
                    return "".join(l[:i] + end)
    return None