order by
@param \Imi\Db\Query\Interfaces\IOrder[] $order
@return string
174479
protected function parseOrder($order)
    {
        if(isset($order[0]))
        {
            $result = ' order by ' . implode(',', $order);
            foreach($order as $item)
            {
                $this->params = array_merge($this->params, $item->getBinds());
            }
            return $result;
        }
        else
        {
            return '';
        }
    }
1084171
public function scopeOrder($query)
    {
        $order = Input::get('order', isset($this->order) ? $this->order : 'id') ?: 'id';
        $direction = Input::get('direction', isset($this->direction) ? $this->direction : 'desc') ?: 'desc';

        return $query->orderBy($order, $direction);
    }
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;
    }
704072
public function order_by( $cols, $order = 'asc' ) 
	{
		if ( !is_array( $cols ) ) 
		{
			$this->orders[] = array( $cols, $order ); return $this;
		}
		else
		{
			foreach( $cols as $key => $col ) 
			{
				if ( is_numeric( $key ) ) 
				{
					$this->orders[] = array( $col, $order );	
				} 
				else 
				{
					$this->orders[] = array( $key, $col );
				}
			}
		}
		
		return $this;
	}
524292
protected function sort($order)
    {
        $ordered = [];

        $matrix = [
            'label'     => 'getLabels',
            'component' => 'getComponents',
            'message'   => 'getMessage',
        ];

        foreach ($order as $identifier) {
            $components = $this->{$matrix[$identifier]}();
            foreach ($components as $component) {
                $index                              = count($ordered);
                $this->indexReverse[$identifier][0] = $index;
                $this->index[$index]                = $identifier;
                $ordered[]                          = $component;
            }
        }

        return $ordered;
    }
1016875
public function orderBy($query = [])
    {
        if (!empty($query))
        {
            $i = 0;

            foreach ($query as $key => $value) {
                $tableName = '';
                $orderBy   = $this->getOrderBy();

                if (strpos($key, '.') === false) {
                    $tableName = $this->table() . '.';
                }

                if ($i>0) {
                    $orderBy .= ', ' . $tableName . $key . ' ' . $value;
                } else {
                    $orderBy .= ' ORDER BY ' . $tableName . $key . ' ' . $value;
                }

                $this->setOrderBy($orderBy);
                $i++;
            }
        }

        return $this;
    }
222512
private function sort($items, $order)
    {
        uasort($items, function (Item $item1, Item $item2) use ($order) {
            return ($item1->getValue() < $item2->getValue()) ? (-1 * $order) : $order;
        });

        return $items;
    }
1080198
public function getFieldByOrder($order)
    {
        foreach ($this->_fields as $field) {
            if ($field instanceof FieldInterface) {
                if ($field->getOrder() == $order) {
                    return $field;
                }
            }
        }

        return null;
    }
291227
public function setSortByColumnOrder($order)
    {
        switch ($order) {
            case 'desc':
                $this->sortByColumnOrder = self::SORT_ORDER_DESC;
                break;
            case 'asc':
                $this->sortByColumnOrder = self:: SORT_ORDER_ASC;
                break;
        }

        return $this;
    }
522061
public static function reverseOrder($order)
	{
		if (!trim($order))
			return $order;

		$parts = explode(',',$order);

		for ($i=0,$n=count($parts); $i<$n; ++$i)
		{
			$v = strtolower($parts[$i]);

			if (strpos($v,' asc') !== false)
				$parts[$i] = preg_replace('/asc/i','DESC',$parts[$i]);
			elseif (strpos($v,' desc') !== false)
				$parts[$i] = preg_replace('/desc/i','ASC',$parts[$i]);
			else
				$parts[$i] .= ' DESC';
		}
		return join(',',$parts);
	}
348730
protected function parseOrder(Query $query, $order)
    {
        foreach ($order as $key => $val) {
            if ($val instanceof Expression) {
                $array[] = $val->getValue();
            } elseif (is_array($val) && preg_match('/^[\w\.]+$/', $key)) {
                $array[] = $this->parseOrderField($query, $key, $val);
            } elseif ('[rand]' == $val) {
                $array[] = $this->parseRand($query);
            } elseif (is_string($val)) {
                if (is_numeric($key)) {
                    list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' ');
                } else {
                    $sort = $val;
                }

                if (preg_match('/^[\w\.]+$/', $key)) {
                    $sort    = strtoupper($sort);
                    $sort    = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : '';
                    $array[] = $this->parseKey($query, $key, true) . $sort;
                } else {
                    throw new Exception('order express error:' . $key);
                }
            }
        }

        return empty($array) ? '' : ' ORDER BY ' . implode(',', $array);
    }
541732
public function thenBy($order)
    {
        $order = LambdaUtils::toSelectCallable($order);
        $this->orders[] = array("property" => $order, "direction" => self::ORDER_ASC);
        return $this;
    }
385165
public function fetchAll($order=array()) {
		$obj = $this->getConnection();
        if (empty($order) == false) {
            foreach ($order as $key => $value) {
                $obj->orderBy($key, $value);
            }
        }
        return $obj->get($this->getDao()->getTableName());
	}
139794
private function sortProperties(array $properties, $order)
    {
        if (is_string($order)) {
            if ($order === 'ASC') {
                ksort($properties);
            } else {
                krsort($properties);
            }
        } elseif (is_array($order)) {
            $properties = array_merge(array_flip($order), $properties);
        }

        return $properties;
    }
495384
public function sortable($order = null)
    {
        if (null === $order) {
            return $this->sortable;
        }

        $this->sortable = $order;
        return $this;
    }
383028
public function orderBy(string $sort, string $order = 'ASC'): self
    {
        $order = 'ASC' === strtoupper($order) ? 'ASC' : 'DESC';
        $this->orderBy = [$sort => $order];
        return $this;
    }
316432
protected function parseOrder(Query $query, $order)
    {
        if (empty($order)) {
            return ' ORDER BY rand()';
        }

        $array = [];

        foreach ($order as $key => $val) {
            if ($val instanceof Expression) {
                $array[] = $val->getValue();
            } elseif ('[rand]' == $val) {
                $array[] = $this->parseRand($query);
            } else {
                if (is_numeric($key)) {
                    list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' ');
                } else {
                    $sort = $val;
                }

                $sort    = in_array(strtolower($sort), ['asc', 'desc'], true) ? ' ' . $sort : '';
                $array[] = $this->parseKey($query, $key, true) . $sort;
            }
        }

        return ' ORDER BY ' . implode(',', $array);
    }