Given the following python list of dictionaries:
results = [[{'id': '001', 'result': [0,0,0,0,1]},
{'id': '002', 'result': [1,1,1,1,1]},
{'id': '003', 'result': [0,1,1,None,None]},
{'id': '004', 'result': [0,None,None,1,0]},
{'id': '005', 'result': [1,0,None,1,1]},
{'id': '006', 'result': [0,0,0,1,1]}],
[{'id': '001', 'result': [1,0,1,0,1]},
{'id': '002', 'result': [1,1,1,1,1]},
{'id': '003', 'result': [0,1,1,None,None]},
{'id': '004', 'result': [0,None,None,1,0]},
{'id': '005', 'result': [1,0,None,1,1]},
{'id': '006', 'result': [1,0,1,0,1]}]
]
I would like to generate a new sorted list (in both python and golang) based on the values of 'result' by comparing results between the players ('id') in each group and then sorting them based on the number of matching entries (None results are discarded and not counted):
During the first round and second round 001 and 006 had nine matching answers:
001 = [0,0,0,0,1] 006 = [0,0,0,1,1] - four matching answers.
During the second round, 001 and 006 had five matching answers:
001 = [1,0,1,0,1] 006 = [1,0,1,0,1] - five matching answers
sorted_results = ['001','006','002','005','003','004']
'001' and '006' are the first two items in the list because they have the highest number of matching results - nine.