Sort array data

@param callable $callback

@return array
422067
private function _sort(callable $callback = null) : array
    {
        $values = $this->getValues();
        if ($callback){
            usort($values, $callback);
        }
        else{
            sort($values);
        }
        return $values;
    }
349027
public function mapWithKeys(callable $callback)
    {
        $result = [];

        foreach ($this->items as $key => $value) {
            $assoc = $callback($value, $key);

            foreach ($assoc as $mapKey => $mapValue) {
                $result[$mapKey] = $mapValue;
            }
        }

        return new static($result);
    }
308409
private function _sortBy(string $field, callable $callback = null) : array
    {
        $values = $this->getValues();
        if (!$callback){
            $callback = 'strnatcmp';
        }
        usort($values, function($a, $b) use($callback, $field){
            if (is_array($a) && is_array($b) && isset($a[$field]) && isset($b[$field])){
                return $callback($a[$field], $b[$field]);
            }
            if (is_object($a) && is_object($b) && property_exists($a, $field) && property_exists($b, $field)){
                return $callback($a->$field, $b->$field);
            }
            return 0;
        });
        return $values;
    }
205851
public static function arrayMap(callable $callback, array $array)
    {
        foreach ($array as $key => $value) {
            $array[$key] = \call_user_func($callback, $value, $key);
        }

        return $array;
    }
826233
public function findIndex(callable $callback)
    {
        $array = $this->getArrayCopy();
        foreach ($array as $key => $value) {
            if ($callback($value, $key, $array) === true) {
                return $key;
            }
        }

        return -1;
    }
1202884
public function sort($callback = null)
    {
        if (is_callable($callback)) {
            usort($this->attributes, $callback);
        } else {
            sort($this->attributes);
        }

        return $this;
    }
304223
function sortCustomKey(callable $closure) {
        $data = $this->data;
        \uksort($data, $closure);
        
        return (new self($data));
    }
22674
public function filter(callable $callback): self
    {
        $collection = Factory::create();
        $index      = 0;
        foreach ($this->items as $key => $value) {
            if ($callback($value, $key, $index++)) {
                $collection->set($key, $value);
            }
        }

        return $collection;
    }
657886
public function sortable(\Closure $callback = null)
    {
        return tap($this, function ($element) use ($callback) {
            app('scaffold.module')->addSortable(
                $element->id(),
                $callback
            );
        });
    }
364126
public function each( callable $callback, $count = 1000 )
	{
		if ( is_null( $this->query->orders ) && is_null( $this->query->unionOrders ) )
		{
			$this->orderBy( $this->model->getQualifiedKeyName(), 'asc' );
		}

		return $this->chunk( $count, function ( $results ) use ( $callback )
		{
			foreach ( $results as $key => $value )
			{
				if ( $callback( $value, $key ) === false )
				{
					return false;
				}
			}
		} );
	}
1263794
static public function fromArrayCallback(array $data, callable $callback) {
		$ret = new FormOptions();
		foreach ( $data as $item ){
			list($value, $text) = $callback($item);
			$ret->add($value, $text);
		}
		return $ret;
	}
1059650
protected function parseCallbacks(array $callbacks)
    {
        foreach (array('before', 'after') as $position) {
            // Remove disabled callbacks
            foreach ($callbacks[$position] as $i => $callback) {
                if ($callback['disabled']) {
                    unset($callbacks[$position][$i]);
                }
            }

            // Order callbacks according to priority index
            uasort($callbacks[$position], function($a, $b) {
                if ($a['priority'] === $b['priority']) {
                    return 0;
                }
                return $a['priority'] < $b['priority'] ? -1 : 1;
            });
        }

        return $callbacks;
    }
446148
public function map(callable $callback): ArrayCollection
    {
        $items = [];

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

        return new static($items);
    }
1327
public static function filter(array $arr, callable $callback): array
    {
        $arrResult = [];

        foreach ($arr as $index => $value) {
            if ($callback($value, $index) === true) {
                $arrResult[] = $value;
            }
        }

        return $arrResult;
    }
1347878
public function filter($callback = null)
    {
        $callback = $callback ?: [$this, 'valueIsEmpty'];
        $output = clone $this;
        $output->exchangeArray([]);

        foreach ($this as $key => $value) {
            if ($callback($value, $key)) {
                $output[$key] = $value;
            }
        }

        return $output;
    }
1311185
private function _last(callable $callback = null)
    {
        $values = $this->getValues();
        if ($callback){
            foreach(array_reverse($values) as $key => $value){
                if ($callback($value, $key)){
                    return $value;
                }
            }
        }
        else{
            return empty($values) ? null : $values[count($values)-1];
        }
        return null;
    }
847026
public function sort(callable $callback = null, $desc = false)
    {
        if (!$callback || !\is_callable($callback)) {
            return $this;
        }

        $items = $this->items;
        uasort($items, $callback);

        return !$desc ? $items : array_reverse($items, true);
    }