nodes: 0, module; 1, function_definition; 2, function_name:hclust_linearize; 3, parameters; 4, block; 5, identifier:U; 6, expression_statement; 7, import_from_statement; 8, expression_statement; 9, return_statement; 10, comment:"""Sorts the rows of a matrix by hierarchical clustering.
  
      Parameters:
          U (ndarray) : matrix of data
  
      Returns:
          prm (ndarray) : permutation of the rows
      """; 11, dotted_name; 12, dotted_name; 13, assignment; 14, call; 15, identifier:scipy; 16, identifier:cluster; 17, identifier:hierarchy; 18, identifier:Z; 19, call; 20, attribute; 21, argument_list; 22, attribute; 23, argument_list; 24, identifier:hierarchy; 25, identifier:leaves_list; 26, call; 27, identifier:hierarchy; 28, identifier:ward; 29, identifier:U; 30, attribute; 31, argument_list; 32, identifier:hierarchy; 33, identifier:optimal_leaf_ordering; 34, identifier:Z; 35, identifier:U
code: def hclust_linearize(U):
      """Sorts the rows of a matrix by hierarchical clustering.
  
      Parameters:
          U (ndarray) : matrix of data
  
      Returns:
          prm (ndarray) : permutation of the rows
      """
  
      from scipy.cluster import hierarchy
      Z = hierarchy.ward(U)
      return hierarchy.leaves_list(hierarchy.optimal_leaf_ordering(Z, U))