Sort by function.

@param string $function
@param string $order

@return SortBy
2310
public function byFunction(
        string $function,
        string $order
    ): SortBy {
        $this->sortsBy[] = [
            'type' => self::TYPE_FUNCTION,
            'function' => $function,
            'order' => $order,
        ];

        return $this;
    }
174528
public function sort ($sort_on, $order = 'desc') {
		$queryString = '<FieldRef Name="'  .$sort_on . '" Ascending="' . $this->api->getSortFromValue($order) . '" />';
		$this->sort_caml = '<OrderBy>' . $queryString . '</OrderBy>';

		return $this;
	}
201826
public function orderBy($sort, $order = null)
    {
        return $this->add('orderBy', $sort . ' ' . (! $order ? 'ASC' : $order), false);
    }
1287529
public static function sortArrayByArray(array $array, array $orderArray)
    {
        $ordered = array();
        foreach ($orderArray as $key) {
            if (array_key_exists($key, $array)) {
                $ordered[$key] = $array[$key];
                unset($array[$key]);
            }
        }
        return $ordered + $array;
    }
471881
public static function sort_terms( $terms, $orderby = 'term_id', $order = 'ASC' ) {

		if ( function_exists( 'wp_list_sort' ) ) {
			$terms = wp_list_sort( $terms, 'term_id', 'ASC' );
		} else {

			if ( 'name' === $orderby ) {
				usort( $terms, '_usort_terms_by_name' );
			} else {
				usort( $terms, '_usort_terms_by_ID' );
			}

			if ( 'DESC' === $order ) {
				$terms = array_reverse( $terms );
			}
		}

		return $terms;
	}
222646
public function orderBy($orderBy = NULL) {
        if (isset($orderBy)) {
            $this->setOrderBy($orderBy);
            return $this;
        }
        return $this->getOrderBy();
    }
313370
public function orderBy($orderBy = null) {
		if (is_array($orderBy))
			$this->orderByClause = $orderBy;
		else
			$this->orderByClause = func_get_args();
		return $this;
	}
20245
public function sort(callable $func = null, callable $ufunc = null, int $flags = 0): self
    {
        Arrays::sort($this->data, $func, $ufunc, $flags);

        return $this;
    }
840711
private function sortableCallByReference($function, $arguments)
    {
        $list = $this->sortableConcreteData();
        $params = array_merge([&$list], $arguments);
        $result = call_user_func_array($function, $params);
        if ($result) {
            $this->sortableResetArray($list);
        }
        return $result;
    }
853997
public function orderBy($field, $order = 'asc'){
        $this->model = $this->model->orderBy(...func_get_args());
        return $this;
    }
213586
protected function applyOrderBy(array $data, $orderBy)
    {
        if (!empty($orderBy)) {
            ArrayHelper::multisort($data, array_keys($orderBy), array_values($orderBy));
        }

        return $data;
    }
769728
private function sortByArray($items, array $order)
    {
        $unordered = [];
        foreach ($items as $content) {
            $unordered[$content->getId()] = $content;
        }

        $ordered = [];
        foreach ($order as $id) {
            if (isset($unordered[$id])) {
                $ordered[] = $unordered[$id];
            }
        }

        return $ordered;
    }
1282819
public function sortPrimaryKeys(array $order = null)
    {
        if (!$order) {
            ksort($this->values);

            return;
        }

        $orderedKeys = array_intersect_key(array_flip($order), $this->values);

        $this->values = array_replace($orderedKeys, $this->values);
    }
1014189
public function andSort(Sort $sort = null) : Sort
    {
        if ($sort === null) {
            return $this;
        }
        $orders = $this->orders;
        foreach ($sort as $order) {
            $orders[] = $order;
        }
        return new Sort($orders);
    }
951679
public function arrangeObject($object, $order = array())
    {

        if (!is_object($object))
            throw new Exception("Please provide a valid Object for the arrangeObject method");
        if (!is_array($order) || empty($order))
            throw new Exception("Please provide a valid orderArray for the arrangeObject method");

        $obj = new stdClass();

        foreach ($order as $key) {
            $obj->$key = $object->$key;
        }
        return $obj;
    }
303428
public function orderBy($key, $order='asc')
    {
        if ($this->isConfigKey($key) && $this->addedJoinsCounter != 0) {
            $this->query->orderBy('config.'.$this->configQueryKey($key), $order);
            return $this;
        }

        $this->query->orderBy($key, $order);
        return $this;
    }
47040
private function sortWithEncryptedOrderBy($values, array $orderBy)
    {
        usort($values, function($entity1, $entity2) use ($orderBy) {
            foreach ($orderBy as $fieldName => $order) {
                $value1 = $this->getFieldValue($entity1, $fieldName);
                $value2 = $this->getFieldValue($entity2, $fieldName);

                if ($value1 < $value2) {
                    return (strtoupper($order) === 'ASC') ? -1 : 1;
                }
                elseif ($value1 > $value2) {
                    return (strtoupper($order) === 'ASC') ? 1 : -1;
                }
            }

            // If we are here is because all the values were equal
            return 0;
        });

        return $values;
    }