def _sort_possible_cpu_topologies(possible, wanttopology):
 scores = collections.defaultdict(list)
 for topology in possible:
  score = _score_cpu_topology(topology, wanttopology)
  scores[score].append(topology)
 desired = []
 desired.extend(scores[3])
 desired.extend(scores[2])
 desired.extend(scores[1])
 desired.extend(scores[0])
 return desired

def _sort_possible_cpu_topologies ( possible , wanttopology ) : scores = collections . defaultdict ( list ) for topology in possible : score = _score_cpu_topology ( topology , wanttopology ) scores [ score ] . append ( topology ) desired = [ ] desired . extend ( scores [ 3 ] ) desired . extend ( scores [ 2 ] ) desired . extend ( scores [ 1 ] ) desired . extend ( scores [ 0 ] ) return desired
sort the topologies in order of preference .