original_docstring: 
              Sort partitions by those we want to check first
              (typically, merging two sites into one is the
              one to try first).
              
docstring: Sort partitions by those we want to check first
  (typically, merging two sites into one is the
  one to try first).
docstring_tokens: Sort partitions by those we want to check first ( typically merging two sites into one is the one to try first ) .
code: def _sort_partitions(partitions_to_sort):
              """
              Sort partitions by those we want to check first
              (typically, merging two sites into one is the
              one to try first).
              """
  
              partition_indices = [(idx, [len(p) for p in partition])
                                   for idx, partition in enumerate(partitions_to_sort)]
  
              # sort by maximum length of partition first (try smallest maximums first)
              # and secondarily by number of partitions (most partitions first, i.e.
              # create the 'least disordered' structures first)
              partition_indices = sorted(partition_indices, key=lambda x: (max(x[1]), -len(x[1])))
  
              # merge at most max_component sites,
              # e.g. merge at most 2 species into 1 disordered site
              partition_indices = [x for x in partition_indices if max(x[1]) <= max_components]
  
              partition_indices.pop(0)  # this is just the input structure
  
              sorted_partitions = [partitions_to_sort[x[0]] for x in partition_indices]
  
              return sorted_partitions
code_tokens: def _sort_partitions ( partitions_to_sort ) : partition_indices = [ ( idx , [ len ( p ) for p in partition ] ) for idx , partition in enumerate ( partitions_to_sort ) ] partition_indices = sorted ( partition_indices , key = lambda x : ( max ( x [ 1 ] ) , - len ( x [ 1 ] ) ) ) partition_indices = [ x for x in partition_indices if max ( x [ 1 ] ) <= max_components ] partition_indices . pop ( 0 ) sorted_partitions = [ partitions_to_sort [ x [ 0 ] ] for x in partition_indices ] return sorted_partitions
short_docstring: Sort partitions by those we want to check first
  (typically, merging two sites into one is the
  one to try first).
short_docstring_tokens: Sort partitions by those we want to check first ( typically merging two sites into one is the one to try first ) .
comment: """
              Sort partitions by those we want to check first
              (typically, merging two sites into one is the
              one to try first).
              """$SEP$# sort by maximum length of partition first (try smallest maximums first)$SEP$# and secondarily by number of partitions (most partitions first, i.e.$SEP$# create the 'least disordered' structures first)$SEP$# merge at most max_component sites,$SEP$# e.g. merge at most 2 species into 1 disordered site$SEP$# this is just the input structure