Always return a valid sort - even if the userid column is missing.
@return array column name => SORT_... constant.
5647
public function get_sort_columns() {
        $result = parent::get_sort_columns();

        $assignment = $this->assignment->get_instance();
        if (empty($assignment->blindmarking)) {
            $result = array_merge($result, array('userid' => SORT_ASC));
        } else {
            $result = array_merge($result, [
                    'COALESCE(s.timecreated, '  . time()        . ')'   => SORT_ASC,
                    'COALESCE(s.id, '           . PHP_INT_MAX   . ')'   => SORT_ASC,
                    'um.id'                                             => SORT_ASC,
                ]);
        }
        return $result;
    }
1124536
protected function order()
    {
        $order = '';
        if (isset($this->request['order']) && count($this->request['order'])) {
            $orderBy = [];
            for ($i = 0, $ien = count($this->request['order']);$i<$ien;$i++) {
                $columnIdx = intval($this->request['order'][$i]['column']);
                $column = $this->columns[$columnIdx];
                if (!isset($column['orderable']) || $column['orderable'] === true) {
                    $orderBy[] = $this->toSQLColumn($column, 2).' '.(!isset($this->request['order'][$i]['dir']) || $this->request['order'][$i]['dir'] === 'asc' ? 'ASC' : 'DESC');
                }
            }
            $order = ' ORDER BY '.implode(', ', $orderBy);
        }

        return $order;
    }
147792
private function getIncompleteOrderFromDB()
    {
        $order = Order::find()->where([
            'user_id' => \Yii::$app->user->id,
            'status' => OrderStatus::STATUS_INCOMPLETE])
            ->one();

        if (empty($order)) {
            $order = new Order();
            $order->uid = $this->generateUniqueId($this->uidPrefix, $this->minOrderUid, $this->maxOrderUid);
            $order->user_id = \Yii::$app->user->id;
            $order->status = OrderStatus::STATUS_INCOMPLETE;
            if ($order->validate()) {
                $order->save();
            }
        }
        return $order;
    }
404445
protected function _getSortCol()
    {
        $aVisibleNames = $this->_getVisibleColNames();
        $iCol = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('sort');
        $iCol = $iCol ? (( int ) str_replace('_', '', $iCol)) : 0;
        $iCol = (!isset($aVisibleNames[$iCol])) ? 0 : $iCol;

        return $iCol;
    }
628070
public function rSort($sort = null)
    {
        if ($sort !== null && ! is_int($sort)) {
            throw new \InvalidArgumentException(
                'Invalid sort type. Sort type must ne integer.',
                E_USER_ERROR
            );
        }

        return $sort === null
            ? rsort($this->storedData)
            : rsort($this->storedData, $sort);
    }
1118598
public function getDefaultOrderColumns()
    {
        /* @var $model ActiveRecord */
        $model = new $this->modelClass;
        $columns = $model->getTableSchema()->columns;
        try {
            $indexes = $model->getDb()->getSchema()->findUniqueIndexes($model->getTableSchema());
            $unique = empty($indexes) ? [] : array_flip(call_user_func_array('array_merge', $indexes));
        } catch (NotSupportedException $e) {
            $unique = null;
        }
        $order = [];
        $modelAttributes = array_flip($model->attributes());
        foreach ($model->getBehaviors() as $name => $behavior) {
            if ($behavior instanceof SortableBehavior) {
                $attributes = [$behavior->attribute];
            } elseif ($behavior instanceof LabelsBehavior) {
                if ($behavior->attributes === null) {
                    continue;
                }
                $attributes = $behavior->attributes;
            } else {
                continue;
            }

            foreach ($attributes as $attribute) {
                if (!isset($modelAttributes[$attribute])) {
                    continue;
                }
                $order[$attribute] = SORT_ASC;
                if ($unique !== null && isset($unique[$attribute]) && isset($columns[$attribute])
                    && !$columns[$attribute]->allowNull
                ) {
                    return $order;
                }
            }
        }

        $order = array_merge($order, array_fill_keys($model->primaryKey(), SORT_ASC));

        return $order;
    }
206340
public function getOrderTableDescription()
    {
        $salesTable = $this->adapter->getTableName('sales_order');
        $adapter = $this->adapter->getConnection('sales');
        $columns = $adapter->describeTable($salesTable);

        return $columns;
    }
194169
protected function getSortableColumn()
    {
        $reader = new AnnotationReader();
        $reflClass = new ReflectionClass($this->getEntityClass());
        foreach ($reflClass->getProperties() as $property) {
            $reflProperty = new ReflectionProperty($this->getEntityClass(), $property->name);
            $annotation = $reader->getPropertyAnnotation($reflProperty, '\Gedmo\Mapping\Annotation\SortablePosition');
            if ($annotation) {
                return $property->name;
            }
        }
    }
1135389
public function sort(Sorting $sorting)
	{
		if (is_callable($sorting->getSortCallback())) {
			call_user_func(
				$sorting->getSortCallback(),
				$this->data_source,
				$sorting->getSort()
			);

			return $this;
		}

		$sort = $sorting->getSort();

		if (!empty($sort)) {
			foreach ($sort as $column => $order) {
				$this->data_source->addOrderBy($this->checkAliases($column), $order);
			}
		} else {
			/**
			 * Has the statement already a order by clause?
			 */
			if (!$this->data_source->getDQLPart('orderBy')) {
				$this->data_source->orderBy($this->checkAliases($this->primary_key));
			}
		}

		return $this;
	}
220120
private function sort()
    {
        if ($this->sort) {
            return $this->sort;
        };
        return $this->sort = array_multisort($this->cleanParam) && ksort($this->cleanParam);
    }
186420
public function get_sort_columns() {
        if (!$this->setup) {
            throw new coding_exception('Cannot call get_sort_columns until you have called setup.');
        }

        if (empty($this->prefs['sortby'])) {
            return array();
        }

        foreach ($this->prefs['sortby'] as $column => $notused) {
            if (isset($this->columns[$column])) {
                continue; // This column is OK.
            }
            if (in_array($column, get_all_user_name_fields()) &&
                    isset($this->columns['fullname'])) {
                continue; // This column is OK.
            }
            // This column is not OK.
            unset($this->prefs['sortby'][$column]);
        }

        return $this->prefs['sortby'];
    }
161195
public function searchableColumnIndex()
    {
        $searchable = [];
        for ($i = 0, $c = count($this->get('columns')); $i < $c; $i++) {
            if ($this->isColumnSearchable($i, false)) {
                $searchable[] = $i;
            }
        }

        return $searchable;
    }
872751
private function getDefaultSortable()
    {
        if (config('columnsortable.default_first_column', false)) {
            $sortBy = array_first($this->sortable);
            if ( ! is_null($sortBy)) {
                return [$sortBy => config('columnsortable.default_direction', 'asc')];
            }
        }

        return null;
    }
852139
protected function sortOrderString()
    {
        $sortOrderComponents = [];
        foreach ($this->getSortOrder() as $sortCriterion) {
            $sortOrderComponents[] = $sortCriterion['fieldName'] . ':'
                    . (($sortCriterion['direction'] === 'descending') ? '0' : '1');
        }
        $sortOrderString = implode(',', $sortOrderComponents);

        return $sortOrderString;
    }
977761
public function getColumnType()
    {
        if (!($type = $this->links->get('simpleType'))) {
            $type = $this->links->get('userType');
        }

        return $type;
    }
570368
public function getColumnsToHideIfUnavailable()
    {
        $out = [];
        foreach ($this->getCells() as $key => $cell) {
            if ($cell->getHideCellIfUnavailable()) {
                $out[] = $key;
            }
        }
        return $out;
    }
1061337
public function getColumnArray() {
        $fields = array('name','type','passThrough','default','nullable',
                        'index','unique','after','pkey');
        $fields = array_flip($fields);
        foreach($fields as $key => &$val)
            $val = $this->{$key};
        unset($val);
        return $fields;
    }