protected function sort() {
    if( !empty( $this->_callback_list ) ) {

      // sort by the priorities, but keep the original indexes (we need it for the repopulation)
      $priority_list = $this->_priority_list;
      asort( $priority_list );

      // repopulate the callbacks based on the new priority "map"
      $tmp                  = $this->_callback_list;
      $this->_callback_list = [];
      foreach( $priority_list as $index => $_ ) {
        $this->_callback_list[] = $tmp[ $index ];
      }

      // reset priority indexes (to match the repopulated array)
      $this->_priority_list = array_values( $priority_list );
    }
  }
protected function sort() {
    if( !empty( $this->_callback_list ) ) {

      // sort by the priorities, but keep the original indexes (we need it for the repopulation)
      $priority_list = $this->_priority_list;
      asort( $priority_list );

      // repopulate the callbacks based on the new priority "map"
      $tmp                  = $this->_callback_list;
      $this->_callback_list = [];
      foreach( $priority_list as $index => $_ ) {
        $this->_callback_list[] = $tmp[ $index ];
      }

      // reset priority indexes (to match the repopulated array)
      $this->_priority_list = array_values( $priority_list );
    }
  }
protected function sort ( ) { if ( ! empty ( $ this -> _callback_list ) ) { // sort by the priorities, but keep the original indexes (we need it for the repopulation) $ priority_list = $ this -> _priority_list ; asort ( $ priority_list ) ; // repopulate the callbacks based on the new priority "map" $ tmp = $ this -> _callback_list ; $ this -> _callback_list = [ ] ; foreach ( $ priority_list as $ index => $ _ ) { $ this -> _callback_list [ ] = $ tmp [ $ index ] ; } // reset priority indexes (to match the repopulated array) $ this -> _priority_list = array_values ( $ priority_list ) ; } }
Sort callbacks based on their priority
Sort callbacks based on their priority