1.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import time
  2. for i in range(10):
  3. a = [{"sort1":2,"sort":2,"index":1},
  4. {"sort1":2,"sort":2,"index":2},
  5. {"sort1":2,"sort":3,"index":3},
  6. {"sort1":2,"sort":3,"index":4},
  7. {"sort1":2,"sort":1,"index":5}]
  8. a.sort(key=lambda x:x["sort"])
  9. a.sort(key=lambda x:x["sort1"])
  10. print(a)
  11. def getBestDocid(list_pair):
  12. # list_pair.sort(key=lambda x:x[3],reverse=True)
  13. # _max_count = max(list_pair[0][3],list_pair[0][1])
  14. # set_candidate = set()
  15. # if list_pair[0][1]==_max_count:
  16. # set_candidate.add(list_pair[0][0])
  17. # for item in list_pair:
  18. # if item[3]==_max_count:
  19. # set_candidate.add(item[2])
  20. # else:
  21. # break
  22. # list_candidate = list(set_candidate)
  23. # list_candidate.sort(key=lambda x:x)
  24. new_pair = []
  25. new_pair.append([list_pair[0][0],list_pair[0][0],list_pair[0][1]])
  26. for item in list_pair:
  27. new_pair.append([item[0],item[2],item[3]])
  28. new_pair.sort(key=lambda x:x[1])
  29. new_pair.sort(key=lambda x:x[2],reverse=True)
  30. return new_pair[0][1]