original_string: public function sort_nodes() {
          $tempnodes = array();
          $this->validate_after_order();
  
          // First content noes.
          foreach ($this->nodes as $node) {
              $after = $node->after;
              $content = $node->content;
              if (($after == null && !empty($content)) || $node->name === 'editprofile') {
                  // Can go anywhere in the cat. Also show content nodes first.
                  $tempnodes = array_merge($tempnodes, array($node->name => $node), $this->find_nodes_after($node));
              }
          }
  
          // Now nodes with no content.
          foreach ($this->nodes as $node) {
              $after = $node->after;
              $content = $node->content;
              if ($after == null && empty($content)) {
                  // Can go anywhere in the cat. Also show content nodes first.
                  $tempnodes = array_merge($tempnodes, array($node->name => $node), $this->find_nodes_after($node));
              }
          }
  
          if (count($tempnodes) !== count($this->nodes)) {
              // Orphan nodes found.
              throw new \coding_exception('Some of the nodes specified contains invalid \'after\' property');
          }
          $this->nodes = $tempnodes;
      }
code: public function sort_nodes() {
          $tempnodes = array();
          $this->validate_after_order();
  
          // First content noes.
          foreach ($this->nodes as $node) {
              $after = $node->after;
              $content = $node->content;
              if (($after == null && !empty($content)) || $node->name === 'editprofile') {
                  // Can go anywhere in the cat. Also show content nodes first.
                  $tempnodes = array_merge($tempnodes, array($node->name => $node), $this->find_nodes_after($node));
              }
          }
  
          // Now nodes with no content.
          foreach ($this->nodes as $node) {
              $after = $node->after;
              $content = $node->content;
              if ($after == null && empty($content)) {
                  // Can go anywhere in the cat. Also show content nodes first.
                  $tempnodes = array_merge($tempnodes, array($node->name => $node), $this->find_nodes_after($node));
              }
          }
  
          if (count($tempnodes) !== count($this->nodes)) {
              // Orphan nodes found.
              throw new \coding_exception('Some of the nodes specified contains invalid \'after\' property');
          }
          $this->nodes = $tempnodes;
      }
code_tokens: public function sort_nodes ( ) { $ tempnodes = array ( ) ; $ this -> validate_after_order ( ) ; // First content noes. foreach ( $ this -> nodes as $ node ) { $ after = $ node -> after ; $ content = $ node -> content ; if ( ( $ after == null && ! empty ( $ content ) ) || $ node -> name === 'editprofile' ) { // Can go anywhere in the cat. Also show content nodes first. $ tempnodes = array_merge ( $ tempnodes , array ( $ node -> name => $ node ) , $ this -> find_nodes_after ( $ node ) ) ; } } // Now nodes with no content. foreach ( $ this -> nodes as $ node ) { $ after = $ node -> after ; $ content = $ node -> content ; if ( $ after == null && empty ( $ content ) ) { // Can go anywhere in the cat. Also show content nodes first. $ tempnodes = array_merge ( $ tempnodes , array ( $ node -> name => $ node ) , $ this -> find_nodes_after ( $ node ) ) ; } } if ( count ( $ tempnodes ) !== count ( $ this -> nodes ) ) { // Orphan nodes found. throw new \ coding_exception ( 'Some of the nodes specified contains invalid \'after\' property' ) ; } $ this -> nodes = $ tempnodes ; }
docstring: Sort nodes of the category in the order in which they should be displayed.
  
  @see \core_user\output\myprofile\tree::sort_categories()
  @throws \coding_exception
docstring_tokens: Sort nodes of the category in the order in which they should be displayed .