nodes: 0, module; 1, function_definition; 2, function_name:_ConstructPartitions; 3, parameters; 4, block; 5, identifier:self; 6, identifier:collection_links; 7, identifier:partitions_per_node; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, return_statement; 15, comment:"""Constructs the partitions in the consistent ring by assigning them to collection nodes
          using the hashing algorithm and then finally sorting the partitions based on the hash value.
          """; 16, assignment; 17, assignment; 18, assignment; 19, identifier:collection_node; 20, identifier:collection_links; 21, block; 22, call; 23, identifier:partitions; 24, identifier:collections_node_count; 25, call; 26, identifier:partitions; 27, list_comprehension; 28, identifier:index; 29, integer:0; 30, expression_statement; 31, for_statement; 32, attribute; 33, argument_list; 34, identifier:len; 35, argument_list; 36, call; 37, for_in_clause; 38, assignment; 39, identifier:_; 40, call; 41, block; 42, identifier:partitions; 43, identifier:sort; 44, identifier:collection_links; 45, attribute; 46, argument_list; 47, identifier:_; 48, call; 49, identifier:hash_value; 50, call; 51, identifier:xrange; 52, argument_list; 53, expression_statement; 54, expression_statement; 55, expression_statement; 56, identifier:partition; 57, identifier:_Partition; 58, identifier:xrange; 59, argument_list; 60, attribute; 61, argument_list; 62, integer:0; 63, identifier:partitions_per_node; 64, assignment; 65, augmented_assignment; 66, assignment; 67, integer:0; 68, binary_operator:partitions_per_node * collections_node_count; 69, attribute; 70, identifier:ComputeHash; 71, call; 72, subscript; 73, call; 74, identifier:index; 75, integer:1; 76, identifier:hash_value; 77, call; 78, identifier:partitions_per_node; 79, identifier:collections_node_count; 80, identifier:self; 81, identifier:hash_generator; 82, attribute; 83, argument_list; 84, identifier:partitions; 85, identifier:index; 86, attribute; 87, argument_list; 88, attribute; 89, argument_list; 90, identifier:self; 91, identifier:_GetBytes; 92, identifier:collection_node; 93, identifier:partition; 94, identifier:_Partition; 95, identifier:hash_value; 96, identifier:collection_node; 97, attribute; 98, identifier:ComputeHash; 99, identifier:hash_value; 100, identifier:self; 101, identifier:hash_generator
code: def _ConstructPartitions(self, collection_links, partitions_per_node):
          """Constructs the partitions in the consistent ring by assigning them to collection nodes
          using the hashing algorithm and then finally sorting the partitions based on the hash value.
          """
          collections_node_count = len(collection_links)
          partitions = [partition._Partition() for _ in xrange(0, partitions_per_node * collections_node_count)]
  
          index = 0
          for collection_node in collection_links:
              hash_value = self.hash_generator.ComputeHash(self._GetBytes(collection_node))
              for _ in xrange(0, partitions_per_node):
                  partitions[index] = partition._Partition(hash_value, collection_node)
                  index += 1
                  hash_value = self.hash_generator.ComputeHash(hash_value)
  
          partitions.sort()
          return partitions