1234567891011121314151617181920212223242526272829303132333435 |
- import time
- for i in range(10):
- a = [{"sort1":2,"sort":2,"index":1},
- {"sort1":2,"sort":2,"index":2},
- {"sort1":2,"sort":3,"index":3},
- {"sort1":2,"sort":3,"index":4},
- {"sort1":2,"sort":1,"index":5}]
- a.sort(key=lambda x:x["sort"])
- a.sort(key=lambda x:x["sort1"])
- print(a)
- def getBestDocid(list_pair):
- # list_pair.sort(key=lambda x:x[3],reverse=True)
- # _max_count = max(list_pair[0][3],list_pair[0][1])
- # set_candidate = set()
- # if list_pair[0][1]==_max_count:
- # set_candidate.add(list_pair[0][0])
- # for item in list_pair:
- # if item[3]==_max_count:
- # set_candidate.add(item[2])
- # else:
- # break
- # list_candidate = list(set_candidate)
- # list_candidate.sort(key=lambda x:x)
- new_pair = []
- new_pair.append([list_pair[0][0],list_pair[0][0],list_pair[0][1]])
- for item in list_pair:
- new_pair.append([item[0],item[2],item[3]])
- new_pair.sort(key=lambda x:x[1])
- new_pair.sort(key=lambda x:x[2],reverse=True)
- return new_pair[0][1]
|