How to reverse sort a list of strings with words that start with uppercase and lowercase letters in Python

2 Answers

0 votes
lst = ['python', 'c', 'Java', 'c++', 'Php', 'c#']

# sort independently to uppercase and lowercase letters
lst = sorted(lst, key=str.lower, reverse=True)


for item in lst:
    print(item, end=" ")


'''
run:
 
python Php Java c++ c# c 
 
'''

 



answered Jun 3, 2017 by avibootz
0 votes
lst = ['python', 'c', 'Java', 'c++', 'Php', 'c#']

lst = sorted(lst, reverse=True)


for item in lst:
    print(item, end=" ")


'''
run:
 
python c++ c# c Php Java 
 
'''

 



answered Jun 3, 2017 by avibootz
...