Sort function
Syntax: Sorted (iterable,key=none,reverse=false)
Iterable: An Iterative object
Key: A collation (sort function), in which each element of an sorted object is passed to the parameter of the function, sorted according to the result of the function operation
Reverse: Whether it is a flashback. True: Flashback, False: Positive sequence
LST = [1,5,6,4,3= sorted (LST)print(LST) # The original list does not change to print # The new list is sorted from small to large
LST = [" Twist Vine "" Gamben " " CIA "" Fox "]print(sorted (lst,key=Lambda# And you can use it with Lamda .
dic = {1: " a ", 3:" b ", 2:" C }dic1 = sorted (DIC) print (DIC1) #
LST = [" Twist Vine "" Gamben " " CIA "" Fox "]def func (s): return Len (s) Print(sorted (Lst,key = func)) # can also be used with functions, sorted by string length
Sorted sort function