Contact: aviboots(AT)netvision.net.il
39,851 questions
51,772 answers
573 users
lst = ["python", "c c++", "rust", "php", "cobol", "java", "csharp"] lst = sorted(lst, key=lambda x: x[2]) print(lst) # b c h p s t v ''' run: ['cobol', 'c c++', 'csharp', 'php', 'rust', 'python', 'java'] '''
def thired_char(s): return s[2] lst = ["python", "c c++", "rust", "php", "cobol", "java", "csharp"] lst.sort(key=thired_char) print(lst) # b c h p s t v ''' run: ['cobol', 'c c++', 'csharp', 'php', 'rust', 'python', 'java'] '''