[Solved] Sorting a list based on associated scores [closed]
I would approach this as follows: from collections import defaultdict # using defaultdict makes the sums easier correlations = defaultdict(int) # default to int (i.e. 0) for i1, i2, correl in strScoresDict: # loop through data correlations[i1] += correl # add score for first item correlations[i2] += correl # and second item output = sorted(correlations, … Read more