th0m45s5helby

Untitled

May 28th, 2021
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. def sortOrders(orderList):
  2.     temp1=[]
  3.     temp2=[]
  4.     for i in orderList:
  5.         for j in i.split()[1:]:
  6.             try:
  7.                 a=int(j)
  8.                 temp1.append(i)
  9.                
  10.             except:
  11.                 temp2.append(i)
  12.             break
  13.    
  14.     temp2=sorted(temp2,key=lambda x:"".join(x.split()[1:]))
  15.     for i in range(1,len(temp2)):
  16.         a="".join(temp2[i].split()[1:])
  17.         b="".join(temp2[i-1].split()[1:])
  18.         if a==b:
  19.             if temp2[i]<temp2[i-1]:
  20.                 temp2[i],temp2[i-1]=temp2[i-1],temp2[i]
  21.     return temp2+temp1
Advertisement
Add Comment
Please, Sign In to add comment