Sorts the internal list of listeners for the given event by priority.
435456
private function sortListeners(string $eventName)
    {
        krsort($this->listeners[$eventName]);
        $this->sorted[$eventName] = [];

        foreach ($this->listeners[$eventName] as &$listeners) {
            foreach ($listeners as $k => $listener) {
                if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
                    $listener[0] = $listener[0]();
                }
                $this->sorted[$eventName][] = $listener;
            }
        }
    }
307099
function removeListener(event, listener) {
  this._events = this._events || {};
  if(event in this._events) {
    this._events[event].splice(this._events[event].indexOf(listener), 1);
  }
  return this;
}
801888
function reorderEvents( node, eventName ) {
		if( node.addEventListener || !node.shoestringData || !node.shoestringData.events ) {
			// add event listner obviates the need for all the callback order juggling
			return;
		}

		var otherEvents = node.shoestringData.events[ eventName ] || [];
		for( var j = otherEvents.length - 1; j >= 0; j-- ) {
			// DOM Events only, Custom events maintain their own order internally.
			if( !otherEvents[ j ].isCustomEvent ) {
				node.detachEvent( "on" + eventName, otherEvents[ j ].callback );
				node.attachEvent( "on" + eventName, otherEvents[ j ].callback );
			}
		}
	}
836544
function ListenerList (emitter, eventId) {
    this._count = 0; // count of "listeners"
    this._methods = null; // null, function, or array of functions
    this._objects = null; // null, context, or array of contexts

    if (debugLevel > 0) {
        this._emitter = emitter; // our parent EventEmitter
        this._eventId = eventId;
        this._counterMap = null; // key: listenerKey, value: count of listeners with same listenerKey
    }
}
178945
public function listen($events, $listener, $priority=0)
    {
        $this->dispatcher->listen($events, $listener, $priority);
    }
312728
public function listen($events, $listener, $priority=0)
    {
        return $this->getDistributor()->listen($events, $listener, $priority);
    }
10872
public <T> void sort(List<T> list, Comparator<T> cmp)
    {
        if(index.size() < list.size())
            for(int i = index.size(); i < list.size(); i++ )
                index.add(i);
        if(list.size() == index.size())
            Collections.sort(index, new IndexViewCompList(list, cmp));
        else
        {
            Collections.sort(index);//so [0, list.size) is at the front
            Collections.sort(index.subList(0, list.size()), new IndexViewCompList(list, cmp));
        }
        prevSize = list.size();
    }
4222
def remove_listener(self, event, callback, single=None, priority=None):
        
        event_stack = self._events[event]
        for x in event_stack:
            if x['callback'] == callback and \
               (single is None or x['single'] == single) and \
               (priority is None or x['priority'] == priority):
                event_stack.remove(x)
                break
        else:
            raise KeyError('Listener not found for "%s": %s' % (event,
                           callback))
727226
private synchronized boolean removeWrapperFromList(EventListenerWrapper<K, V> wrapper, List<EventListenerWrapper<K, V>> listenersList) {
    int index = listenersList.indexOf(wrapper);
    if (index != -1) {
      EventListenerWrapper<K, V> containedWrapper = listenersList.remove(index);
      if(containedWrapper.isOrdered() && --orderedListenerCount == 0) {
        storeEventSource.setEventOrdering(false);
      }
      if (--listenersCount == 0) {
        storeEventSource.removeEventListener(eventListener);
      }
      return true;
    }
    return false;
  }
1249979
public function removeListener(string $eventName, callable $listener, $priority = 0): MediatorInterface
    {
        $this->checkEventName($eventName);
        if (!\array_key_exists($eventName, $this->listeners)) {
            return $this;
        }
        /**
         * @var array      $priorities
         * @var int        $atPriority
         * @var callable[] $listeners
         */
        if ('last' !== $priority) {
            $priorities = $this->listeners[$eventName];
        } else {
            $priorities = \array_reverse($this->listeners[$eventName], \true);
            $priority = 'first';
        }
        $isIntPriority = \is_int($priority);
        foreach ($priorities as $atPriority => $listeners) {
            if ($isIntPriority && $priority !== $atPriority) {
                continue;
            }
            $key = \array_search($listener, $listeners, \true);
            if (\false !== $key) {
                $this->bubbleUpUnsetListener($eventName, $atPriority, $key);
                if ('first' === $priority) {
                    break;
                }
            }
        }
        return $this;
    }
1323501
public void processQueue(
      Predicate<RequestHandler> handlerConsumer,
      Prioritizer prioritizer) {

    Comparator<RequestHandler> comparator =
        prioritizer == null ?
        Ordering.allEqual()::compare :
        (a, b) -> prioritizer.compareTo(
            a.getRequest().getDesiredCapabilities(), b.getRequest().getDesiredCapabilities());

    lock.writeLock().lock();
    try {

      newSessionRequests.stream()
          .sorted(comparator)
          .filter(handlerConsumer)
          .forEach(requestHandler -> {
            if (!removeNewSessionRequest(requestHandler)) {
              log.severe("Bug removing request " + requestHandler);
            }
          });
    } finally {
      lock.writeLock().unlock();
    }
  }
15422
public function get_listener_priority( $event_name, $listener ) {

		if ( ! is_callable( $listener, true ) ) {
			throw new InvalidListenerException( '$listener must be callable.' );
		}

		$priority = has_filter( $event_name, $listener );

		if ( false === $priority ) {
			return null;
		}

		return $priority;
	}
108276
function(sortedInputEvents, protoIRs) {
      var handledEvents = [];
      protoIRs.forEach(function(protoIR) {
        protoIR.associatedEvents.forEach(function(event) {
          if (handledEvents.indexOf(event) >= 0) {
            console.error('double-handled event', event.typeName,
                parseInt(event.start), parseInt(event.end), protoIR);
            return;
          }
          handledEvents.push(event);
        });
      });

      sortedInputEvents.forEach(function(event) {
        if (handledEvents.indexOf(event) < 0) {
          console.error('UNHANDLED INPUT EVENT!',
              event.typeName, parseInt(event.start), parseInt(event.end));
        }
      });
    }
1047934
public static function on($event, $fn, $priority = 0)
    {
        if (!static::bound($event)) {
            static::$events[$event] = [];
        }

        static::$events[$event][] = new Listener($fn, $priority);

        uasort(static::$events[$event], function (Listener $a, Listener $b) {
            return $a->getPriority() < $b->getPriority();
        });
    }
637509
public function getListeners(string $event) : array
    {
        if (empty($this->listeners[$event])) {
            return [];
        }

        if (! isset($this->sorted[$event])) {
            $this->sorted[$event] = $this->sortListeners($this->listeners[$event]);
        }

        return $this->sorted[$event];
    }
401538
public void sort() {
		Collections.sort(list);
		int i=1;
		for (StructureInterface interf:list) {
			interf.setId(i);
			i++;
		}
	}
74379
public function listen($event, $callable, $priority = ListenerPriority::NORMAL)
    {
        $this->addListener($callable, [$event => $priority]);

        return $this;
    }