Sort through each item with a callback.

        :param callback: The callback
        :type callback: callable or None

        :rtype: Collection
168128
def sort(self, callback=None):
        
        items = self.items

        if callback:
            return self.__class__(sorted(items, key=callback))
        else:
            return self.__class__(sorted(items))
1100071
public function sortMultiDimension(Closure $callback)
    {
        foreach ($this->items as &$sortable) {
            uasort($sortable, $callback);
        }
        unset($sortable);

        return $this;
    }
978602
public function each(callable $callback)
    {
        foreach ($this->collection as $key => $value) {
            $callback($value, $key);
        }
    }
948867
public function sort( $callback ) {
		$elements = $this->elements;
		usort( $elements, $callback );
		return $this->new_from_trusted( $elements );
	}
412576
function(callback) {
                var ret,
                    isFunc  = Util.type.function(callback),
                    args    = [].slice.call(arguments, 1);
               
                if (isFunc)
                    ret     = callback.apply(null, args);
                
                return ret;
            }
93511
function eachItem(callback) {
    var self = this;
    function wrappedCallback(err, data) {
      if (err) return callback(err, null);
      if (data === null) return callback(null, null);

      var config = self.service.paginationConfig(self.operation);
      var resultKey = config.resultKey;
      if (Array.isArray(resultKey)) resultKey = resultKey[0];
      var items = jmespath.search(data, resultKey);
      var continueIteration = true;
      AWS.util.arrayEach(items, function(item) {
        continueIteration = callback(null, item);
        if (continueIteration === false) {
          return AWS.util.abort;
        }
      });
      return continueIteration;
    }

    this.eachPage(wrappedCallback);
  }
868074
protected static function filter($items, callable $callback = null)
    {
        if ($callback) {
            return array_filter($items, $callback, ARRAY_FILTER_USE_BOTH);
        }

        return array_filter($items);
    }
597878
function (callback) {
            for (var i = 0, l = this.items.length; i < l; i++) {
                callback(this.items[i], i, this.items);
            }
            return this;
        }
339498
public function sortBy(\Closure $callback , $asc = false)
    {
        $results = array();

        foreach ($this->_items as $key => $value) {
            $results[$key] = $callback($value);
        }

        if ($asc) {
            asort($results);
        } else {
            arsort($results);
        }

        foreach (array_keys($results) as $key) {
            $results[$key] = $this->_items[$key];
        }

        $this->_items = $results;

        return $this;
    }
898176
public static function sort(
        array $array,
        callable $callback,
        int $options = SORT_REGULAR,
        bool $descending = false
    ): array {
        $results = [];

        // First we will loop through the items and get the comparator from a callback
        // function which we were given. Then, we will sort the returned values and
        // and grab the corresponding values for the sorted keys from this array.
        foreach ($array as $key => $value) {
            $results[$key] = $callback($value, $key);
        }

        $descending ? arsort($results, $options) : asort($results, $options);

        // Once we have sorted all of the keys in the array, we will loop through them
        // and grab the corresponding model so we can set the underlying items list
        // to the sorted version. Then we'll just return the collection instance.
        foreach (array_keys($results) as $key) {
            $results[$key] = $array[$key];
        }

        return $results;
    }
600295
def _apply_callback(cls, callback, result):
        
        if not callback.immutable:
            callback.args = (result.id, ) + callback.args
        callback.apply()
597925
def process(self):
        

        with self.lock, self.enlock:
            queue = copy(self.queue)
            self.queue.clear()
            callbacks = copy(self.callbacks)

        with self.lock:
            rm_cb = False
            for ki, vi in queue.items():
                if ki in self.callbacks:
                    for item in vi:
                        for cb in self.callbacks[ki]:
                            if cb(item) is False:
                                callbacks[ki].remove(cb)
                                if not callbacks[ki]:
                                    del callbacks[ki]
                                rm_cb = True

        with self.lock:
            if rm_cb:
                self.callbacks.clear()
                for k, v in callbacks.items():
                    self.callbacks[k].extend(v)
            return len(self.callbacks)
1329333
function(callback) {

		var i = 0,
			count = this._count,
			result = this._createHelperStorage(),
			removed = this._createHelperStorage();

		for (; i < count; i++) {

			if (callback(this._data_values[i], this._data_names[i], this._data_uids[i], i)) {

				result.push(this._data_uids[i], this._data_values[i], this._data_names[i]);

			} else {

				removed.push(this._data_uids[i], this._data_values[i], this._data_names[i]);

			}

		}

		this._assignStorage(result);
		this._setLength(this._data_uids.length);

		removed.uids.length && this._fire('items_removed', removed.getObject());

		this._fire('collection_changed');

	}
409396
public function sort(callable $callback, bool $keySort = false): self
    {
        $keys   = $this->keys;
        $values = $this->values;

        if ($keySort) {
            uasort($keys, $callback);
            $values = array_replace($keys, $values);
        } else {
            uasort($values, $callback);
            $keys = array_replace($values, $keys);
        }

        $this->keys   = array_values($keys);
        $this->values = array_values($values);

        return $this;
    }
1046896
public function sort(callable $callback = null) : ArrayList
    {
        $values = $this->_sort($callback);
        $this->setValues($values);
        return $this;
    }
337603
public function sort(Closure $callback = null): CollectionInterface
    {
        $array = $this->toArray();

        if (is_null($callback)) {
            sort($array);
        } else {
            usort(
                $array,
                $callback
            );
        }

        return static::make($array);
    }
1153479
public function map(callable $callback): Collection
    {
        $keys = array_keys($this->items);
        $items = array_map($callback, $this->items, $keys);

        return new static(array_combine($keys, $items));
    }