original_string: public function sort(PageInterface $page, $order_by = null, $order_dir = null, $sort_flags = null)
      {
          if ($order_by === null) {
              $order_by = $page->orderBy();
          }
          if ($order_dir === null) {
              $order_dir = $page->orderDir();
          }
  
          $path = $page->path();
          $children = $this->children[$path] ?? [];
  
          if (!$children) {
              return $children;
          }
  
          if (!isset($this->sort[$path][$order_by])) {
              $this->buildSort($path, $children, $order_by, $page->orderManual(), $sort_flags);
          }
  
          $sort = $this->sort[$path][$order_by];
  
          if ($order_dir !== 'asc') {
              $sort = array_reverse($sort);
          }
  
          return $sort;
      }
code: public function sort(PageInterface $page, $order_by = null, $order_dir = null, $sort_flags = null)
      {
          if ($order_by === null) {
              $order_by = $page->orderBy();
          }
          if ($order_dir === null) {
              $order_dir = $page->orderDir();
          }
  
          $path = $page->path();
          $children = $this->children[$path] ?? [];
  
          if (!$children) {
              return $children;
          }
  
          if (!isset($this->sort[$path][$order_by])) {
              $this->buildSort($path, $children, $order_by, $page->orderManual(), $sort_flags);
          }
  
          $sort = $this->sort[$path][$order_by];
  
          if ($order_dir !== 'asc') {
              $sort = array_reverse($sort);
          }
  
          return $sort;
      }
code_tokens: public function sort ( PageInterface $ page , $ order_by = null , $ order_dir = null , $ sort_flags = null ) { if ( $ order_by === null ) { $ order_by = $ page -> orderBy ( ) ; } if ( $ order_dir === null ) { $ order_dir = $ page -> orderDir ( ) ; } $ path = $ page -> path ( ) ; $ children = $ this -> children [ $ path ] ?? [ ] ; if ( ! $ children ) { return $ children ; } if ( ! isset ( $ this -> sort [ $ path ] [ $ order_by ] ) ) { $ this -> buildSort ( $ path , $ children , $ order_by , $ page -> orderManual ( ) , $ sort_flags ) ; } $ sort = $ this -> sort [ $ path ] [ $ order_by ] ; if ( $ order_dir !== 'asc' ) { $ sort = array_reverse ( $ sort ) ; } return $ sort ; }
docstring: Sort sub-pages in a page.
  
  @param PageInterface   $page
  @param string $order_by
  @param string $order_dir
  
  @return array
docstring_tokens: Sort sub - pages in a page .