Generate ORDER clause from user-supplied string or array

@param  string|array $order  OPTIONAL An SQL ORDER clause.
@return Zend_Db_Table_Select
347056
protected function _order(Zend_Db_Table_Select $select, $order)
    {
        if (!is_array($order)) {
            $order = array($order);
        }

        foreach ($order as $val) {
            $select->order($val);
        }

        return $select;
    }
72733
public static function getOrder($order = null)
    {
        switch ($order) {
            case self::ENVIRONMENT:
                self::$_breakChain = true;
                $languages         = self::getEnvironment() + self::getBrowser() + self::getDefault();
                break;

            case self::ZFDEFAULT:
                self::$_breakChain = true;
                $languages         = self::getDefault() + self::getEnvironment() + self::getBrowser();
                break;

            default:
                self::$_breakChain = true;
                $languages         = self::getBrowser() + self::getEnvironment() + self::getDefault();
                break;
        }

        return $languages;
    }
1269071
public function query(array $order)
    {
        Datasheet::set($order);
        $result = Helper::request(Helper::GATEWAY_TRADEQUERY, ['AuthCode']);
        return $this->callback($result);
    }
1210752
public function orderBy($columns, string $order = 'ASC')
	{
		$this->orderings[] =
		[
			'column' => is_array($columns) ? $columns : [$columns],
			'order'  => ($order === 'ASC' || $order === 'asc') ? 'ASC' : 'DESC',
		];

		return $this;
	}
168584
public function cuSelectAsArray($tableName, $where = '', $order = '', $limit = '')
    {

        $data_array = [];
        $where      = trim($where);
        $order      = trim($order);
        $limit      = trim($limit);
        if ($where === false) {
            $where = '';
        }
        if ($where !== '') {
            $where = ' WHERE ' . $where;
        }
        if ($order !== '') {
            $order = ' ORDER BY ' . $order;
        }
        if ($limit !== '') {
            $limit = ' LIMIT ' . $limit;
        }

        /** @noinspection SqlNoDataSourceInspection */
        $q      = 'SELECT * FROM `%s` %s %s %s;';
        $q      = sprintf($q, $tableName, $where, $order, $limit);
        $result = $this->query($q);

        if ($result !== false) {
            while ($data = $result->fetch_assoc()) {
                $data_array[] = $data;
            }
        }

        return $data_array;
    }
490927
protected function processOrder($order, $context)
    {
        if ($order instanceof Order || $order instanceof OrderByIsNull) {
            $column = $this->processColumnOrSubQuery($order->column, $context);

            if ($column === $order->column) {
                return $order;
            } elseif ($order instanceof Order) {
                return new Order($column, $order->isDescending);
            } else {
                return new OrderByIsNull($column, $order->areNullFirst);
            }
        }

        if ($order instanceof ExplicitOrder) {
            $column = $this->processColumnOrSubQuery($order->column, $context);

            $values = [];
            foreach ($order->order as $index => $value) {
                $values[$index] = $this->processValueOrSubQuery($value, $context);
            }

            if ($column === $order->column && $values === $order->order) {
                return $order;
            } else {
                return new ExplicitOrder($column, $values, $order->areOtherFirst);
            }
        }

        return $order;
    }
99925
public function newOrder($order)
    {
        $sorter = new Sorter();
        $sorter->target = $this;
        $sorter->order = $order;
        $sorter->query = (new Query())
                            ->from(static::tableName())
                            ->where(['and',
                                ['!=', 'id', $this->id],
                                ['category_id' => $this->category_id]
                            ])
                            ->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])
                            ->indexBy('id');
        return $sorter->run();
    }
1188260
public function setOrder($order)
    {
        $this->_order = $order;
        $this->_state->order = $order;

        return $this;
    }
1334261
public function orderBy($column, $order = Order::ASC)
    {
        $this->orders[] = [$column, $order];
        return $this;
    }
47144
protected function getOrderQuery( $orders = array() )
	{
		if( is_array( $orders ) && count( $orders ) )
		{
			$order = array();
			foreach( $orders as $key => $value )
				$order[] = $key.' '.$value;
			$orders = ' ORDER BY '.implode( ', ', $order );
		}
		else
			$orders = '';
		return $orders;
	}
753542
protected function generatePopOrderSql($options = [])
    {
        $orderPart = 'ORDER BY priority ASC';
        if (isset($options['pop_order']) && $options['pop_order'] === self::POP_ORDER_FIFO) {
            $orderPart = 'ORDER BY created_at ASC';
        }

        return $orderPart;
    }
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 '';
        }
    }
1231726
public function setOrder(\Core\Entity\Order $order = null) {
        $this->order = $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);
    }
657932
public function createOrder($order = array())
    {
        $myOrder = new Order($order);
        $response = OrderService::createOrder($myOrder);

        if (isset($response["orderCode"])) {
            //success
            return $response;
        } else {
            Error::throwError("apierror");
        }
    }
90252
public function setOrder($order)
    {
        if (!in_array($order, [self::ORDER_ASC, self::ORDER_DESC])) {
            throw new LogicException('Invalid order argument.');
        }

        $this->order = $order;

        return $this;
    }
943770
protected function recode_choice_order($order) {
        $neworder = array();
        foreach (explode(',', $order) as $id) {
            if ($newid = $this->get_mappingid('question_answer', $id)) {
                $neworder[] = $newid;
            }
        }
        return implode(',', $neworder);
    }