Sort list of strings ignoring upper/lower case
The sort() method and the sorted() function take a key argument: var.sort(key=lambda v: v.upper()) The function named in key is called for each value and the return value is used when sorting, without affecting the actual values: >>> var=[‘ant’,’bat’,’cat’,’Bat’,’Lion’,’Goat’,’Cat’,’Ant’] >>> sorted(var, key=lambda v: v.upper()) [‘ant’, ‘Ant’, ‘bat’, ‘Bat’, ‘cat’, ‘Cat’, ‘Goat’, ‘Lion’] To sort Ant … Read more