Determine how a field needs to be ordered.

@param        $orderName
@param string $defaultOrder

@return array

@since  1.1.0

@author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>
514920
public static function getOrderDirection($orderName, $defaultOrder = 'ASC')
    {
        $order = ORDER_DIRECTION[$defaultOrder];

        if (StringHelper::startsWith($orderName, '-')) {
            return [str_replace('-', '', $orderName), $order[1]];
        }

        return [$orderName, $order[0]];
    }
662851
public function hasCustomOrdering($orderColumn)
    {
        $methodName = camel_case('laratables_order_'.$orderColumn);

        if (method_exists($this->class, $methodName)) {
            return $methodName;
        }

        return false;
    }
1057476
public function findRelation($entity, $relationName, $orderColumn = null, $orderType = null) {
        $this->load();
        $mapper = MapperBuilder::buildFromClassName($this->mapping, get_class($entity));
        $relation = $mapper->getRelation($relationName);
        $relationMapper = MapperBuilder::buildFromName($this->mapping, $relation->getEntity());

        $selectQuery = "SELECT tmain.* FROM `" . $relationMapper->getTable() . "` tmain ";
        $joinQuery = QueryBuilder::buildJoinRelationQuery($relation, "tmain", "j1");
        $whereQuery = "WHERE j1." . $relation->getLocalColumn() . " = '" . $entity->getId() . "'";

        $orderQuery = "";
        if (!is_null($orderColumn)) {
            $orderQuery .= "ORDER BY $orderColumn ";
            if (!is_null($orderType)) {
                $orderQuery .= "$orderType";
            } else {
                $orderQuery .= "ASC";
            }
        }

        $query = $selectQuery . $joinQuery . $whereQuery . $orderQuery;
        $queryResult = $this->getDataSource()->query($query);
        if ($queryResult) {
            $collection = new Collection($relationMapper->getClass(), $queryResult, $relationMapper);
        } else {
            $collection = new Collection($relationMapper->getClass(), array(), $relationMapper);
        }

        return $collection;
    }
814473
public function getWeekViewForOrderCollection(OrderCollection $orderCollection)
    {
        $weekView = new WeekView(new \DateTime(), null, 'D d');

        $windows = $this->findForSelectWindowForOrderCollection($orderCollection, $weekView->getEndDate());

        foreach ($windows as $window)
        {
            $weekView->addObject($window);
        }

        return $weekView;
    }
170609
private function getSortOrder($name = '-datepublish')
    {
        $parts = explode(' ', $name);
        $fieldName = $parts[0];
        $sort = 'ASC';
        if (isset($parts[1])) {
            $sort = $parts[1];
        }

        if ($fieldName[0] === '-') {
            $fieldName = substr($fieldName, 1);
            $sort = 'DESC';
        }

        return [$fieldName, (strtoupper($sort) === 'ASC')];
    }
1206183
public static function all(string $orderField = null, string $orderDirection = null): array
    {
        $select = static::select();

        if ($orderField !== null) {
            $select->orderBy($orderField, $orderDirection);
        }

        $data = [];
        foreach ($select->fetchAll() as $r) {
            $data[] = new static($r);
        }

        return $data;
    }
987623
public function getDefaultOrder($alias = 't')
    {
        if (is_null($this->_defaultOrder)) {
            $this->_defaultOrder = $this->getDescriptorDefaultOrder('{alias}');
        }
        $sortBy = [];
        foreach ($this->_defaultOrder as $key => $value) {
            $sortBy[strtr($key, ['{alias}' => $alias])] = $value;
        }

        return $sortBy;
    }
718282
public static function groupBy (string $field, string $order="DESC") : array
	{
		$order = static::validateOrder($order);
		return static::findBySql("SELECT * FROM ".static::$tableName." GROUP BY {$field} ORDER BY id {$order}");
	}
278844
public function setDefaultOrders( $orders )
    {
        $this->defaultOrders = array();

        foreach ( $orders as $order => $dir )
        {
            $this->defaultOrders[$order] = $dir;
        }

        return $this;
    }
59726
private Orderer getOrderer(HFClient client, String ordererName) throws InvalidArgumentException {
        Orderer orderer = null;
        Node o = orderers.get(ordererName);
        if (o != null) {
            orderer = client.newOrderer(o.getName(), o.getUrl(), o.getProperties());
        }
        return orderer;
    }
565838
public function getSortOrder($name = '-datepublish')
    {
        // If we don't get a string, we can't determine a sortorder.
        if (!is_string($name)) {
            return false;
        }

        $parts = explode(' ', trim($name));
        $fieldname = $parts[0];
        $sort = 'ASC';
        if (isset($parts[1])) {
            $sort = $parts[1];
        }

        if ($fieldname[0] == '-') {
            $fieldname = substr($fieldname, 1);
            $sort = 'DESC';
        }

        return [$fieldname, (strtoupper($sort) == 'ASC')];
    }
1257859
protected function _getOrderField() {
		$orderList = $this->_getOrderList();
		$result = null;
		foreach ($orderList as $orderField) {
			if (!$this->hasField($orderField)) {
				continue;
			}

			$result = $orderField;
			break;
		}

		return $result;
	}
984934
public function getOrdering()
    {
        // if the following code fails, fall back to this default ordering
        $orderBy = $this->conf['sortWithoutSearchword'];

        // if sorting in FE is allowed
        if ($this->conf['showSortInFrontend']) {
            $piVarsField = $this->pObj->piVars['sortByField'];
            $piVarsDir = $this->pObj->piVars['sortByDir'];
            $piVarsDir = ($piVarsDir == '') ? 'asc' : $piVarsDir;
            if (!empty($piVarsField)) { // if an ordering field is defined by GET/POST
                $isInList = GeneralUtility::inList($this->conf['sortByVisitor'], $piVarsField);
                if ($this->conf['sortByVisitor'] != '' && $isInList) {
                    $orderBy = $piVarsField . ' ' . $piVarsDir;
                }
                // if sortByVisitor is not set OR not in the list of
                // allowed fields then use fallback ordering in "sortWithoutSearchword"
            }
            // if sortByVisitor is not set OR not in the list of
            //allowed fields then use fallback ordering in "sortWithoutSearchword"
        } else {
            if (!empty($this->pObj->wordsAgainst)) { // if sorting is predefined by admin
                $orderBy = $this->conf['sortByAdmin'];
            } else {
                $orderBy = $this->conf['sortWithoutSearchword'];
            }
        }

        return $orderBy;
    }
1318850
public static function fields($orderId, $orderAmount, $orderName = null, $orderDesc = null)
	{

		$fields = self::gateway()->endpoint(array(
			'orderId'     => $orderId,
			'orderAmount' => $orderAmount,
			'orderName'   => $orderName,
			'orderDesc'   => $orderDesc,
		));

		foreach ($fields as $key => $val) {
			echo '<input
				type="hidden"
				name="' . htmlentities($key) . '"
				value="' . htmlentities($val) . '">
			';
		}

	}
503697
public function addOrderBy($field, $order = 'ASC')
    {
        $alias = self::DEFAULT_TABLE_ALIAS;
        if (strpos($field, '.') > 0) {
            //monta os joins
            $newAliasField = $this->associationQueryFields($field);
            $alias = $newAliasField['alias'];
            $field = $newAliasField['field'];
        }
        $this->queryBuilder->addOrderBy($this->getFullFieldName($field, $alias), $order);

        return $this;
    }
1001998
public Orderer newOrderer(String name, String grpcURL) throws InvalidArgumentException {
        clientCheck();
        return newOrderer(name, grpcURL, null);
    }
67863
final public function orderBy($orderby, $direction = '')
    {
        if (strtolower($direction) == 'random') {
            $orderby = ''; // Random results want or don't need a field name
            $direction = $this->_randomKeyword;
        } elseif (trim($direction) != '') {
            $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' ' . $direction : ' ASC';
        }


        if (strpos($orderby, ',') !== FALSE) {
            $temp = array();
            foreach (explode(',', $orderby) as $part) {
                $part = trim($part);
                if (!in_array($part, $this->arrayAliasedTables)) {
                    $part = $this->identifiers(trim($part));
                }
                $temp[] = $part;
            }

            $orderby = implode(', ', $temp);
        } else if ($direction != $this->_randomKeyword) {
            $orderby = $this->identifiers($orderby);
        }

        $orderbyStatement = $orderby . $direction;

        $this->arrayOrderBy[] = $orderbyStatement;
        if ($this->arrayCaching === TRUE) {
            $this->arrayCacheOrderBy[] = $orderbyStatement;
            $this->arrayCacheExists[] = 'orderby';
        }

        return $this;
    }