nodes: 0, module; 1, function_definition; 2, function_name:_eigsorted; 3, parameters; 4, block; 5, identifier:cov; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, identifier:asc; 13, True; 14, comment:"""
      Computes eigenvalues and eigenvectors of a covariance matrix and returns
      them sorted by eigenvalue.
  
      Parameters
      ----------
      cov : ndarray
          covariance matrix
  
      asc : bool, default=True
          determines whether we are sorted smallest to largest (asc=True),
          or largest to smallest (asc=False)
  
      Returns
      -------
      eigval : 1D ndarray
          eigenvalues of covariance ordered largest to smallest
  
      eigvec : 2D ndarray
          eigenvectors of covariance matrix ordered to match `eigval` ordering.
          I.e eigvec[:, 0] is the rotation vector for eigval[0]
      """; 15, assignment; 16, assignment; 17, not_operator; 18, comment:# sort largest to smallest; 19, block; 20, expression_list; 21, pattern_list; 22, call; 23, identifier:order; 24, call; 25, identifier:asc; 26, expression_statement; 27, subscript; 28, subscript; 29, identifier:eigval; 30, identifier:eigvec; 31, attribute; 32, argument_list; 33, attribute; 34, argument_list; 35, assignment; 36, identifier:eigval; 37, identifier:order; 38, identifier:eigvec; 39, slice; 40, identifier:order; 41, attribute; 42, identifier:eigh; 43, identifier:cov; 44, identifier:eigval; 45, identifier:argsort; 46, identifier:order; 47, subscript; 48, identifier:np; 49, identifier:linalg; 50, identifier:order; 51, slice; 52, unary_operator; 53, integer:1
code: def _eigsorted(cov, asc=True):
      """
      Computes eigenvalues and eigenvectors of a covariance matrix and returns
      them sorted by eigenvalue.
  
      Parameters
      ----------
      cov : ndarray
          covariance matrix
  
      asc : bool, default=True
          determines whether we are sorted smallest to largest (asc=True),
          or largest to smallest (asc=False)
  
      Returns
      -------
      eigval : 1D ndarray
          eigenvalues of covariance ordered largest to smallest
  
      eigvec : 2D ndarray
          eigenvectors of covariance matrix ordered to match `eigval` ordering.
          I.e eigvec[:, 0] is the rotation vector for eigval[0]
      """
  
      eigval, eigvec = np.linalg.eigh(cov)
      order = eigval.argsort()
      if not asc:
          # sort largest to smallest
          order = order[::-1]
  
      return eigval[order], eigvec[:, order]