list = [3,2,1,5,6,9,8,4] print list for i in range(0, len(list)): for j in range(0, len(list)-1): if list[j] < list[j+1]: list[j], list[j+1] = list[j+1], list[j] print list ready = [1,2,3,4,5,6] priority = [0,2,3,3,10,7,10] print ready print priority print "" for i in range(0, len(ready)): for j in range(0, len(ready)-1): if priority[ready[j]] < priority[ready[j+1]]: ready[j], ready[j+1] = ready[j+1], ready[j] print ready