Returns table sort block

@param array
@param string
@param string
@param string|null
@return Eden\Block\Sort
553200
public function sort(array $query, $key, $label, $url = null) 
	{
		Argument::i()
			->test(2, 'string')
			->test(3, 'string')
			->test(4, 'string', 'null');
			
		$block = Sort::i($query, $key, $label);
		
		if($url) {
			$block->setUrl($url);
		}
		
		return $block;
	}
536286
public static function orderArray($array, $order)
    {
        $ordered = [];

        foreach ($order as $key) {
            if (array_key_exists($key, $array)) {
                $ordered[$key] = $array[$key];
            }
        }

        return $ordered;
    }
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;
  }
341004
public static function cellSort($a, $b)
    {
        sscanf($a, '%[A-Z]%d', $ac, $ar);
        sscanf($b, '%[A-Z]%d', $bc, $br);

        if ($ar == $br) {
            return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
        }
        return ($ar < $br) ? -1 : 1;
    }
1082619
protected function sortJson(&$array)
    {
        foreach ($array as &$value) {
            if (is_array($value) && isset($value[0])) {
                sort($value);
            } elseif (is_array($value)) {
                $this->sortJson($value);
            }
        }

        return ksort($array);
    }
588364
function sortBy(array, attr) {
  assert(Array.isArray(array));
  return array.sort(function(a,b) {
    a = a[attr];
    b = b[attr];
    return (a < b) ? -1 : ((a > b) ? 1 : 0);
  });
}
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;
    }
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;
    }
320586
protected static function _sortObjects(&$a, &$b)
  {
    $key = self::$sortKey;

    for($i=0, $count=count($key); $i<$count; $i++){
      if ( isset(self::$sortDirection[$i]) ){
        $direction = self::$sortDirection[$i];
      }

      if ( isset(self::$sortCase[$i]) ){
        $caseSensitive = self::$sortCase[$i];
      }

      if ( isset(self::$sortLocale[$i]) ){
        $locale = self::$sortLocale[$i];
      }

      $va = $a->$key[$i];
      $vb = $b->$key[$i];

      if ( (is_bool($va) or is_numeric($va)) and (is_bool($vb) or is_numeric($vb)) ){
        $cmp = $va - $vb;
      }
      elseif ( $caseSensitive ){ 
        $cmp = strcmp($va, $vb, $locale);
      }
      else {
        $cmp = strcasecmp($va, $vb, $locale);
      }

      if ( $cmp > 0 ){

        return $direction;
      }

      if ( $cmp < 0 ){
        return -$direction;
      }
    }

    return 0;
  }
1160798
function orderBy (arr) {
  var comparator = null
  var sortKeys
  arr = util.convertArray(arr)

  // determine order (last argument)
  var args = util.toArray(arguments, 1)
  var order = args[args.length - 1]
  if (typeof order === 'number') {
    order = order < 0 ? -1 : 1
    args = args.length > 1 ? args.slice(0, -1) : args
  } else {
    order = 1
  }

  // determine sortKeys & comparator
  var firstArg = args[0]
  if (!firstArg) {
    return arr
  } else if (typeof firstArg === 'function') {
    // custom comparator
    comparator = function (a, b) {
      return firstArg(a, b) * order
    }
  } else {
    // string keys. flatten first
    sortKeys = Array.prototype.concat.apply([], args)
    comparator = function (a, b, i) {
      i = i || 0
      return i >= sortKeys.length - 1
        ? baseCompare(a, b, i)
        : baseCompare(a, b, i) || comparator(a, b, i + 1)
    }
  }

  function baseCompare (a, b, sortKeyIndex) {
    var sortKey = sortKeys[sortKeyIndex]
    if (sortKey) {
      if (sortKey !== '$key') {
        if (util.isObject(a) && '$value' in a) a = a.$value
        if (util.isObject(b) && '$value' in b) b = b.$value
      }
      a = util.isObject(a) ? util.getPath(a, sortKey) : a
      b = util.isObject(b) ? util.getPath(b, sortKey) : b
    }
    return a === b ? 0 : a > b ? order : -order
  }

  // sort on a copy to avoid mutating original array
  return arr.slice().sort(comparator)
}
216242
public static function asort(array &$array, int $sort_flags = SORT_REGULAR): void
    {
        self::decorateOriginalArray($array);
        uasort($array, function ($a, $b) use ($sort_flags) {
            if ($a[1] == $b[1])
                return $a[0] - $b[0];
            $arr = [
                - 1 => $a[1],
                1 => $b[1]
            ];
            asort($arr, $sort_flags);
            reset($arr);
            return key($arr);
        });
        self::undecorateSortedArray($array);
    }
392921
public static function sort($array, Closure $callback)
    {
        $results = [];

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

        return $results;
    }
802773
protected function ksortRecursive(&$array)
    {
       foreach ($array as &$value) {
           if (is_array($value)) {
               $this->ksortRecursive($value);
           }
       }
       ksort($array, SORT_NATURAL);

       return $array;
    }
482857
private function sortHeaders($a, $b)
    {
        $lowerA = strtolower($a);
        $lowerB = strtolower($b);
        $aPos = array_key_exists($lowerA, $this->order) ? $this->order[$lowerA] : -1;
        $bPos = array_key_exists($lowerB, $this->order) ? $this->order[$lowerB] : -1;

        if (-1 === $aPos && -1 === $bPos) {
            // just be sure to be determinist here
            return $a > $b ? -1 : 1;
        }

        if (-1 == $aPos) {
            return 1;
        } elseif (-1 == $bPos) {
            return -1;
        }

        return $aPos < $bPos ? -1 : 1;
    }
75986
public function sortBlocks( array $sortArray )
    {
        $sortedBlocks = array();

        foreach( $sortArray as $sortItem )
        {
            $blocksToBeRemoved = array();
            
            foreach( $this->attributes['blocks'] as $block )
            {
                if ( $block->attribute('id') === $sortItem )
                    $sortedBlocks[] = $block;
                
                if ( $block->toBeRemoved() )
                    $blocksToBeRemoved[] = $block;
            }
        }

        $sortedBlocks = array_merge( $sortedBlocks, $blocksToBeRemoved );

        $this->attributes['blocks'] = $sortedBlocks;
    }
699355
public function sortBy(array $fields) : self
    {
        if ($this->count() == 0) {
            return clone $this;
        }

        /** @var array|bool[] $isMethod */
        $isMethod = [];
        $values = [];

        foreach ($fields as $name => $options) {
            foreach ($this->elements as $key => $element) {
                if (is_array($element)) {
                    $values[$name][$key] = $element[$name];
                } else {
                    if (!array_key_exists($name, $isMethod)) {
                        $isMethod[$name] = method_exists($element, $name);
                    }

                    if ($isMethod[$name]) {
                        $values[$name][$key] = call_user_func([$element, $name]);
                    } else {
                        $values[$name][$key] = $element->$name;
                    }
                }
            }
        }

        $args = [];

        foreach ($fields as $name => $options) {
            $args[] = $values[$name];
            $args[] = $options;
        }

        $return = $this->elements;
        $args[] = &$return;

        call_user_func_array('array_multisort', $args);

        $clone = clone $this;
        $clone->elements = $return;

        return $clone;
    }
27081
public function sort($sorts)
    {
        usort($this->rows, 
            function ($a, $b) use ($sorts) {
                $cmp = 0;
                foreach ($sorts as $sort => $direction) {
                    if (is_string($direction)) {
                        $cmp = is_numeric($a[$sort]) && is_numeric($b[$sort]) ? 
                            $a[$sort] - $b[$sort] : strcmp($a[$sort], $b[$sort]);
                        $cmp = $direction === 'asc' ? $cmp : - $cmp;
                    } else if (is_callable($direction)) {
                        $cmp = $direction($a[$sort], $b[$sort]);
                    }
                    if ($cmp !== 0) {
                        break;
                    }
                }
                return $cmp;
            }
        );
        return $this;
    }