Process the sorting, also break sorting.

@param array $table
@param Config $config

@return array
975418
private function processSort(array $table, Config $config)
    {
        if ($config['sort']) {
            $cols = array_reverse($config['sort']);

            foreach ($cols as $colName => $direction) {
                Sort::mergeSort($table, function ($elementA, $elementB) use ($colName, $direction) {
                    if ($elementA[$colName] == $elementB[$colName]) {
                        return 0;
                    }

                    if ($direction === 'asc') {
                        return $elementA[$colName] < $elementB[$colName] ? -1 : 1;
                    }

                    return $elementA[$colName] > $elementB[$colName] ? -1 : 1;
                });
            }
        }

        if ($config['break']) {
            foreach ($config['break'] as $colName) {
                Sort::mergeSort($table, function ($elementA, $elementB) use ($colName) {
                    if ($elementA[$colName] == $elementB[$colName]) {
                        return 0;
                    }

                    return $elementA[$colName] < $elementB[$colName] ? -1 : 1;
                });
            }
        }

        return $table;
    }
471727
protected function sortTable(TableNode $table)
    {
        $raw_table = $table->getTable();
        sort($raw_table);
        return new TableNode($raw_table);
    }
270803
public function select($table, $cond=null, $fields='*', $sort=null, $limit=null, $calc=false)
	{
		$ds = $this->ds();
		$cond = SqlHelper::parse_cond($ds,$cond);
		if ($cond) $cond = "WHERE {$cond}";
		if ($sort) $sort = "ORDER BY {$sort}";
		
		$qfields = SqlHelper::qfields($fields,$table);
		$table = SqlHelper::qtable($table);
		
		$result = Sql::read($ds, Sql::MODE_READ_GETALL, [
				"SELECT {$qfields} FROM {$table} {$cond} {$sort}",
				empty($limit) ? false : $limit,
				$calc
			]);
		return $result;
	}
903607
protected function buildSorts(array $config)
    {
        $sorts = [];

        foreach ((isset($config['sorts']) ? $config['sorts'] : []) as $name => $sort) {
            $sort = $this->buildSort(array_merge(['name' => $name], $sort), $config);
            $sorts[$sort->getName()] = $sort;
        }

        return $sorts;
    }
462286
public function rewriteTable($tableName, $tableConfig = null)
    {
        if ($this->hasTable($tableName)) {
            $this->deleteTable($tableName);
        }

        return $this->create($tableName, $tableConfig);
    }
192384
public static function process($config = array())
	{
		foreach (static::$upload->getAllFiles() as $file)
		{
			$file->setConfig($config);
			$file->validate();
		}
	}
1180954
protected function processSassConfiguration(array $config)
    {
        // changed from css_preprocessor to css_preprocessor for 3.0
        if (in_array($config['css_preprocessor'], array('sass', 'scssphp'))) {
            if ($config['assets_dir'] === Configuration::DEFAULT_ASSETS_DIR) {
                $config['assets_dir'] = Configuration::DEFAULT_ASSETS_DIR_SASS;
            }
            if ($config['customize']['bootstrap_output'] === Configuration::DEFAULT_BOOTSTRAP_OUTPUT) {
                $config['customize']['bootstrap_output'] = Configuration::DEFAULT_BOOTSTRAP_OUTPUT_SASS;
            }
            if ($config['customize']['bootstrap_template'] === Configuration::DEFAULT_BOOTSTRAP_TEMPLATE) {
                $config['customize']['bootstrap_template'] = Configuration::DEFAULT_BOOTSTRAP_TEMPLATE_SASS;
            }
        }

        return $config;
    }
855961
public function renderSort( $config = [] ) {

		$sortView = CodeGenUtil::isAbsolutePath( $this->sortView ) ? $this->sortView : "$this->template/$this->sortView";

        return $this->render( $sortView, [ 'widget' => $this ] );
	}
1242192
protected function buildSort(array $config, array $parentConfig)
    {
        return $this->sortBuilder->build($this->prepareConfig($config, $parentConfig));
    }
394059
public function getPage( $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable	= $this->getModelTable();

		// Sorting ----------

		$sort = new Sort([
			'attributes' => [
				'id' => [
					'asc' => [ "$modelTable.id" => SORT_ASC ],
					'desc' => [ "$modelTable.id" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Id'
				],
				'title' => [
					'asc' => [ "$modelTable.title" => SORT_ASC ],
					'desc' => [ "$modelTable.title" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Title'
				],
				'type' => [
					'asc' => [ "$modelTable.type" => SORT_ASC ],
					'desc' => [ "$modelTable.type" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Type'
				],
				'status' => [
					'asc' => [ "$modelTable.id" => SORT_ASC ],
					'desc' => [ "$modelTable.id" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Status'
				],
				'total' => [
					'asc' => [ "$modelTable.grandTotal" => SORT_ASC ],
					'desc' => [ "$modelTable.grandTotal" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Total'
				],
				'cdate' => [
					'asc' => [ "$modelTable.createdAt" => SORT_ASC ],
					'desc' => [ "$modelTable.createdAt" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Created At'
				],
				'udate' => [
					'asc' => [ "$modelTable.modifiedAt" => SORT_ASC ],
					'desc' => [ "$modelTable.modifiedAt" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Updated At'
				]
			],
			'defaultOrder' => [ 'cdate' => 'SORT_ASC' ]
		]);

		if( !isset( $config[ 'sort' ] ) ) {

			$config[ 'sort' ] = $sort;
		}

		// Query ------------

		if( !isset( $config[ 'query' ] ) ) {

			$config[ 'hasOne' ] = true;
		}

		// Filters ----------

		// Filter - Status
		$status	= Yii::$app->request->getQueryParam( 'status' );

		if( isset( $status ) ) {

			if( isset( $modelClass::$urlRevStatusMap[ $status ] ) ) {

				$config[ 'conditions' ][ "$modelTable.status" ] = $modelClass::$urlRevStatusMap[ $status ];
			}
		}

		// Searching --------

		$searchCol	= Yii::$app->request->getQueryParam( 'search' );

		if( isset( $searchCol ) ) {

			$search = [ 'title' => "$modelTable.title", 'description' => "$modelTable.description" ];

			$config[ 'search-col' ] = $search[ $searchCol ];
		}

		// Reporting --------

		$config[ 'report-col' ]	= [
			'title' => "$modelTable.title", 'description' => "$modelTable.description", 'content' => "$modelTable.content"
		];

		// Result -----------

		return parent::getPage( $config );
	}
585365
public function sort(array $array): array {
        $array = \array_values($array);
        $length = \count($array);

        if (0 === $length || 1 === $length) return $array;

        for ($i = 0; $i < $length; $i++) {
            $min = $i;
            for ($j = $i; $j < $length; $j++) {
                if (Comparator::lessThan($array[$j], $array[$min])) {
                    $min = $j;
                }
            }
            $tmp = $array[$min];
            $array[$min] = $array[$i];
            $array[$i] = $tmp;
        }
        return $array;
    }
1159664
public function sort($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'title'     => '',
            'column'    => '',
            'direction' => 'asc',
            'sort'      => ''
        ));

        $translator = $this->getObject('translator');

        //Set the title
        if(empty($config->title)) {
            $config->title = ucfirst($config->column);
        }

        //Set the direction
        $direction	= strtolower($config->direction);
        $direction 	= in_array($direction, array('asc', 'desc')) ? $direction : 'asc';

        $url = clone $this->getTemplate()->url();

        $query              = $url->getQuery(1);
        $query['sort']      = $config->column;
        $query['direction'] = ($direction == 'desc' ? 'asc' : 'desc'); // toggle
        $url->setQuery($query);

        $html  = '<a href="'.$url.'" data-k-tooltip=\'{"container":".k-ui-container","delay":{"show":500,"hide":50}}\' data-original-title="'.$translator->translate('Click to sort by this column').'">';
        $html .= $translator->translate($config->title);

        if($config->column == $config->sort)
        {
            $direction = $direction == 'desc' ? 'descending' : 'ascending'; // toggle
            $html .= '<span class="k-sort-'.$direction.'" aria-hidden="true"></span>';
            $html .= '<span class="k-visually-hidden">'.$direction.'</span>';
        }

        $html .= '</a>';


        return $html;
    }
60876
public static function insert($table, $data = array(), $config = array()) {
        DB::connect();
        return DB::$connection->insert($table, $data, $config);
    }
1252802
public function processConfig(array $config)
    {
        $writer = new NativeXmlWriter();
        $writer->openMemory();
        $writer->setIndent(true);
        $writer->setIndentString(str_repeat(' ', 4));

        $writer->startDocument('1.0', 'UTF-8');
        $writer->startElement('data');

        foreach ($config as $sectionName => $data) {
            if (!is_array($data)) {
                $writer->writeElement($sectionName, (string) $data);
            } else {
                $this->addBranch($sectionName, $data, $writer);
            }
        }

        $writer->endElement();
        $writer->endDocument();

        return $writer->outputMemory();
    }
905334
public function sort(array $sorting)
    {
        foreach ($sorting as $key => $value) {
            $column = isset($this->sortMapping[$key])
                ? $this->sortMapping[$key]
                : current($this->qb->getRootAliases()) . '.' . $key;

            $this->qb->addOrderBy($column, $value);
        }
    }
616317
protected function buildColumnActions(array $config)
    {
        $columnActions = [];

        foreach ((isset($config['column_actions']) ? $config['column_actions'] : []) as $name => $action) {
            $action = $this->buildColumnAction(array_merge(['name' => $name], $action), $config);
            $columnActions[$action->getName()] = $action;
        }

        return $columnActions;
    }
1333213
protected function processCSSConfig($config)
    {
        if (!ArrayLib::is_associative($config)) {
            return array_fill_keys(array_values($config), null); 
        }
        
        return $config;
    }