I am trying to sort a list by multiple conditions using this code.
lis = sorted([lsDataSorted[i:i+8] for i in range(0,len(lsDataSorted),8)],key=lambda x:(x[7],int(x[5])-int(x[6]),x[5],x[0]),reverse=True)
Now, we don't need to bother talking about what each object is, but we see that I have an "reverse" sorting function. Now, my last condition x[0]
happens to be a list of names. By using the reverse=True
, we know that the sorting will be in reverse order (z-a). My question is, can I "reverse" back to normal only for the last condition? If yes, then how?