Return an array of module method objects
@param string $order Order Column, default ABS(name)
@return array
342619
public function getMethods ($order = FALSE)
	{
		
		// If the methods have not been loaded
		
		if (!$this->methods || $order !== FALSE)
		{
			
			// Set the method class name
			
			$class		=  $this->getNamespace () . '\Method';
			
			// Load the methods
			
			$params['where'][]	= array ('module_id', $this->get ('id'));
			$params['orderby']	= $order?: 'ABS(name)';
			
			$this->methods		= $class::_getObjects ($params);
			
		}
		
		// Return the methods
		
		return $this->methods;
		
	}
375755
public function order($order, $context) {
		if (!$order) {
			return [];
		}
		if (is_string($order)) {
			return [$order => 1];
		}
		if (!is_array($order)) {
			return [];
		}
		foreach ($order as $key => $value) {
			if (!is_string($key)) {
				unset($order[$key]);
				$order[$value] = 1;
				continue;
			}
			if (is_string($value)) {
				$order[$key] = strtolower($value) === 'asc' ? 1 : -1;
			}
		}
		return $order;
	}
675656
private function getOrderAndSeed($order)
    {
        @list($order, $seed) = explode(':', $order, 2);

        if (empty($seed)) {
            $seed = $this->getRandomSeed();
        }

        if (!is_numeric($seed)) {
            $this->showError("Could not use '$seed' as seed.");
        }

        return array($order, $seed);
    }
383028
public function orderBy(string $sort, string $order = 'ASC'): self
    {
        $order = 'ASC' === strtoupper($order) ? 'ASC' : 'DESC';
        $this->orderBy = [$sort => $order];
        return $this;
    }
155403
public function orderItems(Order $order)
    {
        return response()->json([
            'errors' => false,
            'data' => $order->items->map(function($item) {
                $item->product->load('options');
                return $item;
            }),
        ]);
    }
1080198
public function getFieldByOrder($order)
    {
        foreach ($this->_fields as $field) {
            if ($field instanceof FieldInterface) {
                if ($field->getOrder() == $order) {
                    return $field;
                }
            }
        }

        return null;
    }
1008661
public function getBestRenderLocales($ordered = self::ORDER_LANG) {
        $locales = [];
        $this->getServerLocales();

        foreach($this->getClientLocales() as $locale) {
            /** @var Locale $locale  */

            $loc = $this->serverLocales->getBestMatchingLocaleForLocale($locale);
            if($loc && !in_array($loc, $locales)) {
                $locales[]  = $loc;
            }
        }
        if(count($locales) == 0) {
            if($this->defaultLocale)
                $locales[] = $this->defaultLocale;
            else {
                $locales[] = $this->getServerLocales()[0] ?? NULL;
            }
        }

        if($ordered & self::ORDER_STRUCT) {
            $locs = [];
            foreach($locales as $loc) {
                /** @var Locale $loc */
                $lang = $loc->getLanguage();

                $locs[$lang][] = $loc;
            }

            if($ordered & self::ORDER_LANG) {
                foreach($locs as &$ll)
                    usort($ll, LocaleCollection::LANG_SORT_CALLBACK);
            } elseif($ordered & self::ORDER_REG) {
                foreach($locs as &$ll)
                    usort($ll, LocaleCollection::REG_SORT_CALLBACK);
            }

            return $locs;
        }

        return $locales;
    }
1250855
public function order($order)
    {
        $order = $this->prepareNames(func_get_args(),false);
        $this->order = $order;
        return $this;
    }
824390
private function toPayPalItems($order)
    {
        $items = [];

        foreach ($order->items as $shopItem) {

            if ($shopItem->price > 0) {

                $item = new Item();

                $item->setName(substr($shopItem->displayName, 0, 127))
                    ->setDescription($shopItem->sku)
                    ->setCurrency($shopItem->currency)
                    ->setQuantity($shopItem->quantity)
                    ->setTax($shopItem->tax)
                    ->setPrice($shopItem->price);

                $items[] = $item;
            }
        }
        if ($discount = $order->totalDiscount) {
            $item = new Item();

            $item->setName('Discount')
                ->setDescription('discount')
                ->setCurrency($shopItem->currency)
                ->setQuantity(1)
                ->setTax(0)
                ->setPrice(-$discount);

            $items[] = $item;
        }

        return $items;
    }
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;
	}
1193895
public function applyOrder($order)
    {
        switch ($order) {
            case 'time':
                $this->orderBy(['created_at' => SORT_ASC]);
                break;

            case 'supports':
            default:
                $this->orderBy(['(supports / pow((((UNIX_TIMESTAMP(NOW()) - created_at) / 3600) + 2),1.8) )' => SORT_DESC]);
                break;
        }

        return $order;
    }
211760
private function getOrderNormalizer()
    {
        return function(Options $options, $order) {
            foreach ($order as $field => $sort) {
                if (!is_string($sort) || !is_string($field) || !in_array(strtolower($sort), ['asc', 'desc'])) {
                    throw new Exception(
                        'Order value should be an array of string (["field" => $key]), got '.gettype($sort)
                    );
                }
            }

            return $order;
        };
    }
712784
private function formatArray($order, $item, $remove = false, $lastItem = true)
    {
        return [
            'remove'   => $remove,
            'lastItem' => $lastItem,
            'item'     => [
                'quantity' => $item->getQuantity(),
                'total'    => $this->moneyFormatter->format(
                    $item->getTotal(),
                    $order->getCurrencyCode(),
                    $order->getLocaleCode()
                ),
                'subtotal' => $this->moneyFormatter->format(
                    $item->getSubTotal(),
                    $order->getCurrencyCode(),
                    $order->getLocaleCode()
                ),
            ],
            'order' => [
                'total' => $this->moneyFormatter->format(
                    $order->getTotal(),
                    $order->getCurrencyCode(),
                    $order->getLocaleCode()
                ),
                'items-total' => $this->moneyFormatter->format(
                    $order->getItemsTotal(),
                    $order->getCurrencyCode(),
                    $order->getLocaleCode()
                ),
            ],
            'payments' => $this->getPaymentsTotals($order),
        ];
    }
926436
protected function normalizeOrder($order)
    {
        switch (strtolower($order)) {
            case 'asc':
                return 'asc';
            case 'desc':
                return 'desc';
            default:
                throw new QueryException(sprintf('Unsupported sorting method "%s" in query "%s"', $this->getType($order), $this->model->entity()));

        }
    }
1285220
protected function getTotalQtyItemsOrdered($order) {
        $qty = 0;
        $orderedItems = $order->getItemsCollection();
        foreach ($orderedItems as $item)
        {
            if (!$item->isDummy()) {
                $qty += (int)$item->getQtyOrdered();
            }
        }
        return $qty;
    }
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);
	}
244977
public function orderBy($order) 
    {
        
        $this->sql .= ' ORDER BY ';
        
        foreach($order as $column) {
            $this->sql .= $this->quoteColumnName($column[0]) .' '. $column[1] . ', ';
        }
        
        $this->sql = trim($this->sql, ', ');
        
        return $this;
    }