code: static public function sort(array &$nodes)
      {
          $args = func_get_args();
          unset($args[0]);
  
          $sort = array();
          $tmp = array();
  
          foreach ($args as $k => $arg) {
              if (is_string($arg)) {
                  $tmp[$k] = array();
  
                  if (preg_match('#^@?[a-z_0-9]+$#Di', $arg)) {
                      if ($arg[0] === '@') {
                          $name = substr($arg, 1);
                          foreach ($nodes as $node) {
                              $tmp[$k][] = (string)$node[$name];
                          }
                      } else {
                          foreach ($nodes as $node) {
                              $tmp[$k][] = (string)$node->$arg;
                          }
                      }
                  } elseif (preg_match('#^current\\(\\)|text\\(\\)|\\.$#i', $arg)) {
                      /**
                       * If the XPath is current() or text() or . we use this node's textContent
                       */
                      foreach ($nodes as $node) {
                          $tmp[$k][] = dom_import_simplexml($node)->textContent;
                      }
                  } else {
                      foreach ($nodes as $node) {
                          $_nodes = $node->xpath($arg);
                          $tmp[$k][] = (empty($_nodes)) ? '' : (string)$_nodes[0];
                      }
                  }
              } else {
                  $tmp[$k] = $arg;
              }
  
              /**
               * array_multisort() wants everything to be passed as reference so we have to cheat
               */
              $sort[] =& $tmp[$k];
          }
  
          $sort[] =& $nodes;
  
          call_user_func_array('array_multisort', $sort);
      }
docs: Sort an array of nodes
  
  Note that nodes are sorted in place, nothing is returned
  
  @see sortedXPath
  
  @param    array &$nodes Array of SimpleXMLElement
  @return    void