Sort multi-dimensional array

@param array $array
@param string $key
@param int $type
@return array
192405
public function orderBy(array $array, $key = 'sort', $type = SORT_DESC)
    {
        $array2 = [];
        foreach ($array as $k => $v) {
            $array2[$k] = $v[$key];
        }
        array_multisort($array2, $type, $array);

        return $array;
    }
1051906
public static function delete(&$array, $key)
	{
		if (is_null($key))
		{
			return false;
		}

		if (is_array($key))
		{
			$return = array();
			foreach ($key as $k)
			{
				$return[$k] = static::delete($array, $k);
			}
			return $return;
		}

		$key_parts = explode('.', $key);

		if (! is_array($array) or ! array_key_exists($key_parts[0], $array))
		{
			return false;
		}

		$this_key = array_shift($key_parts);

		if (! empty($key_parts))
		{
			$key = implode('.', $key_parts);
			return static::delete($array[$this_key], $key);
		}
		else
		{
			unset($array[$this_key]);
		}

		return true;
	}
1244527
public static function array_sort(array $array, $order, $seq = '') {
    if (!$order) {
      return $array;
    }
    if (is_array($order)) {
      $key = array_keys($order)[0];
      $seq = $order[$key];
      $order = $key;
    }
    $seq = strtoupper($seq) == 'DESC' ? -1 : 1;
    usort( $array, function ($a, $b) use ($order, $seq) {
      $a = $a[$order];
      $b = $b[$order];
      $diff = is_string($a) && is_string($b) ? strcmp($a, $b) : $a - $b;
      return $seq * ceil($diff);
    });
    return $array;
  }
122667
public function exportKeyList(Array $array, $type = 'keyList') {
    $that = $this;
    return
      sprintf('array(%s)', A::implode($array, ',', function ($item, $key) use($that, $type) {
        if (is_array($item)) {
          // damit wir wenn wir exportList machen und ein objekt mit hilfsfunktion exportKeyList benutzen zu exportList() wieder zurückgehen können
          $value = $type === 'keyList' ? $that->exportKeyList($item) : $that->exportList($item);
        } elseif($item instanceof \stdClass) {
          $value = $that->exportStdClass($item, 'keyList');
        } else {
          $value = $that->exportValue($item);
        }
        
        return sprintf('%s=>%s', var_export((string) $key,TRUE), $value);
      })
    );
  }
1322023
public static function encodeArray(array $array, string $type = null): array
    {
        foreach ($array as &$v) {
            $v = self::run(self::ENCODER, $v, $type);
        }

        return $array;
    }
84864
public static function sortByKeyString($a, $b, $key) {
    $a_title = (is_array($a) && isset($a[$key])) ? $a[$key] : '';
    $b_title = (is_array($b) && isset($b[$key])) ? $b[$key] : '';

    return strnatcasecmp($a_title, $b_title);
  }
567076
public function indexBy(array $data, $key)
    {
        $newData = [];
        foreach ($data as $row) {
            $newData[$row[$key]] = $row;
        }

        return $newData;
    }
1358684
public static function getObjectWithKey(array $array, $key)
    {
        foreach ($array as $object) {
            if (is_array($object) && array_key_exists($key, $object)) {
                return $object;
            }
        }

        return null;
    }
109373
public static function sortByKey(array $args, array $keys) {
		$keyArray = $noArray = array();
		foreach ($keys as $value) {
			if (isset( $args[$value] )) {
				$keyArray[$value] = $args[$value];
			}
		}
		foreach ($args as $key => $value) {
			if (!in_array($key, $keys)) {
				$noArray[$key] = $value;
			}
		}
		return array_merge($keyArray, $noArray);
	}
1262949
public static function decodeArrayFromBase64(array $array, string $type = null): array
    {
        foreach ($array as &$v) {
            $v = self::run(self::DECODER, \base64_decode($v), $type);
        }

        return $array;
    }
120861
protected function sortByArray($array, $order)
    {
        $keys = array_keys($array);
        
        return array_merge(
            array_flip(
                array_intersect($order, $keys) +
                array_diff($keys, $order)
            ),
            $array
        );
    }
392921
public static function sort($array, Closure $callback)
    {
        $results = [];

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

        return $results;
    }
105942
public function sort($key, array $options = null)
    {
        $argStrs = ['ARGV[1]'];
        $args = [$key];

        $argvCounter = 1;

        foreach($options as $k => $v)
        {
            switch(strtolower($k))
            {
                case 'by':
                    $argStrs[] = "'BY'";
                    $argStrs[] = 'ARGV[' . (++$argvCounter) . ']';
                    $args[] = $v;
                    break;
                case 'limit':
                    $argStrs[] = "'LIMIT'";
                    $argStrs[] = 'ARGV[' . (++$argvCounter) . ']';
                    $args[] = $v[0];
                    $argStrs[] = 'ARGV[' . (++$argvCounter) . ']';
                    $args[] = $v[1];
                    break;
                case 'get':
                    foreach(is_array($v) ? $v : [$v] as $pattern)
                    {
                        $argStrs[] = "'GET'";
                        $argStrs[] = 'ARGV[' . (++$argvCounter) . ']';
                        $args[] = $pattern;
                    }
                    break;
                case 'sort':
                    $argStrs[] = 'ARGV[' . (++$argvCounter) . ']';
                    $args[] = $v;
                    break;
                case 'alpha':
                    if($v)
                    {
                        $argStrs[] = "'ALPHA'";
                    }
                    break;
                case 'store':
                    $argStrs[] = "'STORE'";
                    $argStrs[] = 'ARGV[' . (++$argvCounter) . ']';
                    $args[] = $v;
                    break;
            }
        }

        $argStr = implode(',', $argStrs);

        $result = $this->eval(<<<STR
return redis.call('sort', {$argStr}) 
STR
        , $args);

        return $result;
    }
562899
public static function order(array $array, array $columns)
    {
        $arrayMultisortParameters = [];
        foreach ($columns as $column => $order) {
            $arrayMultisortParameters[] = array_column($array, $column);
            $arrayMultisortParameters[] = $order;
        }
        $arrayMultisortParameters[] = &$array;
        array_multisort(...$arrayMultisortParameters);

        return $array;
    }
491766
public static function sortArrayByKey($array, $array_key, $direction = SORT_DESC, $sort_flags = SORT_REGULAR)
    {
        $output = [];

        if (!is_array($array) || !$array) {
            return $output;
        }

        foreach ($array as $key => $row) {
            $output[$key] = $row[$array_key];
        }

        array_multisort($output, $direction, $sort_flags, $array);

        return $array;
    }
428951
public function forget($key, $type)
	{
		if(is_array($key))
		{
			return $this->forgetItem($this->storageKey($key), $type);
		}

		if(is_string($key))
		{
			return $this->forgetItem($key, $type);
		}

		if(is_int($key))
		{
			return $this->forgetItem($this->storageKey([$key]), $type);
		}
	}
448943
public static function encodeArrayToBase64(array $array, string $type = null): array
    {
        foreach ($array as &$v) {
            $v = \base64_encode(self::run(self::ENCODER, $v, $type));
        }

        return $array;
    }