# sorted (iterable,Key=none,reverse=false)
# keyAccepts a function that accepts only one element, and the default isNone
# reverseis a Boolean value. Default isFalseIn front of the line,TrueRank in ascending order, that is, the condition of the backward row
#Sort by age
Students = [(' John ',A,15), (' Jane ',B,12), (' Dave ',B,10)]
R1 =Sorted (Students,key=Lambda s:s[2])
# <class ' list ': [(' Dave ', ' B ', ' Ten '), (' Jane ', ' B ', '), (' John ', ' A ', 15)]
#String sort, collation: lowercase<Capital<Odd<Even
s =' Asdf234gdsdsf23 '
R3 ="". Join (Sorted (s,key=Lambda x: (X.isdigit ())))
#Number in the rear' asdfGDSdsf23423 '
R4 ="". Join (Sorted (s,key=Lambda x: (X.isdigit (), X.isdigit ()andint (x)%2 = =0)))
#Number in the rear, even in the rear' asdfGDSdsf33242 '
R5 ="". Join (Sorted (s,key=Lambda x: (X.isdigit (), X.isdigit ()andint (x)%2 = =0, X.isupper ())))
#Number in the rear, even after, uppercase in the rear' asdfdsfGDS33242 '
R6 ="". Join (Sorted (s,key=Lambda x: (X.isdigit (), X.isdigit ()andint (x)%2 = =0, X.isupper (), x)))
#Numbers in the rear, even in the rear, uppercase after, sorted alphabetically or numerically in ascending order' addffssDGS33224 '
#Positive number in the back of the previous negative,Positive numbers from small to large,Negative numbers from big to small
List1 = [4, -8,7,5,0, -25]
R1 = sorted (List1key=lambda x: (x < 0))
# First the negative number is moved to the back <class ' list ';: [4, 7, 5, 0,-8,-2,-5]
r2 = sorted (List1, key= lambda x: (x < 0abs (x))
# <class ' list ';: [0, 4, 5, 7,-2, -5,-8] /span>
python3-Note-c-005-function-sorted