I would like to order a list using two conditions, sorting by the file extension (txt first) asc and by the file name desc.NameError
# Input list:
lst = ["d.csv", "a.TXT", "b.txt", "c.csv"]
# Expected output:
lst = ["b.txt", "a.TXT", "d.csv", "c.csv"]
I have a sample code, but it uses default order (I have found any posibility to set the reverse option for the second condidiotion only)
sorted(lst, key = lambda x:(x.split(".")[-1].lower(), x.split(".")[0].lower()))