Gets the default column sorter
497443
function getDefaultSorter(colName) {
		return function(a, b, dir){

			var 
				firstRec = dir == 'asc' ? a : b,
				secondRec = dir == 'asc' ? b : a,

				fA = firstRec[colName].toLowerCase(),
				fB = secondRec[colName].toLowerCase();

			// Handle numbers
			if (fA<fB) return -1
			if (fA>fB) return +1
			return 0
		};
	}
247001
def sort(self, cmp=None, key=None, reverse=False):
        

        def _DefaultKey(value):
            """Default key func is to create a list of all fields."""
            result = []
            for key in self.header:
                # Try sorting as numerical value if possible.
                try:
                    result.append(float(value[key]))
                except ValueError:
                    result.append(value[key])
            return result

        key = key or _DefaultKey
        # Exclude header by copying table.
        new_table = self._table[1:]

        if cmp is not None:
            key = cmp_to_key(cmp)

        new_table.sort(key=key, reverse=reverse)

        # Regenerate the table with original header
        self._table = [self.header]
        self._table.extend(new_table)
        # Re-write the 'row' attribute of each row
        for index, row in enumerate(self._table):
            row.row = index
458505
private static Sort first(String columnName, Sort.Order order) {
        return Sort.on(columnName, order);
    }
648897
private void restoreColumnSettings(IDialogSettings settings) {
		this.sresList.getTable().layout(true);
		restoreColumnWidths(settings);
		this.sortColumn = Column.NAME;
		try {
			final String columnName = settings.get(ID + ".sortColumn"); //$NON-NLS-1$
			if (!Strings.isNullOrEmpty(columnName)) {
				this.sortColumn = Column.valueOf(columnName);
				if (this.sortColumn == null) {
					this.sortColumn = Column.NAME;
				}
			}
		} catch (Throwable exception) {
			//
		}
		switch (this.sortColumn) {
		case NAME:
			sortByName();
			break;
		case LOCATION:
			sortByLocation();
			break;
		default:
		}
	}
338215
function() {
				var name = '',
				customColsName = '';
				for (var i = 0; i < customCols.length; i++) {
					name = fm.getColumnName(customCols[i]);
					customColsName +='<td class="elfinder-cwd-view-th-'+customCols[i]+' sortable-item">'+name+'</td>';
				}
				return customColsName;
			}
1139154
protected function sortColumns()
    {
        $this->config->getColumns()->sort(function (FieldConfig $a, FieldConfig $b) {
            return $a->getOrder() > $b->getOrder();
        });
    }
1118983
private static Sort getSort(String... columnNames) {
        Sort key = null;
        for (String s : columnNames) {
            if (key == null) {
                key = first(s, Sort.Order.DESCEND);
            } else {
                key.next(s, Sort.Order.DESCEND);
            }
        }
        return key;
    }
539839
public function getDefaults()
    {
        if (!isset($this->_defaults))
        {
            $defaults = array();
            $columns = $this->getColumns();

            foreach ($columns as $name => $description) {
                $defaults[$name] = $description->default;
            }

            $this->_defaults = $defaults;
        }

        return $this->_defaults;
    }
1115826
def sortable_column(attribute, default_direction = nil, options = nil)
      if options.nil? && (options = Hash.try_convert(default_direction))
        default_direction = nil
      end
      default_direction ||= 'desc'
      options ||= {}
      name = options[:name] || attribute.humanize
      selected = @table_sort_info[:attribute].to_s == attribute
      if selected
        direction = @table_sort_info[:direction]
        new_direction = direction.to_s == 'desc' ? 'asc' : 'desc'
        classes = "selected #{direction}"
      else
        classes = ''
        new_direction = default_direction
      end
      link_to(name, url_for(sort: "#{attribute}.#{new_direction}"), class: classes)
    end
48941
public function getSortOrder()
    {
        $sortOrder = isset($this->requestParams[self::PARAM_SORT_ORDER]) ?
            $this->requestParams[self::PARAM_SORT_ORDER] : self::DEFAULT_SORT_ORDER;
        $sortOrder = mb_strtolower($sortOrder);

        if (!in_array($sortOrder, ['asc', 'desc'])) {
            $sortOrder = self::DEFAULT_SORT_ORDER;
        }

        return $sortOrder;
    }
82986
protected function _sort()
    {
        if (!isset($this->_sorts) || count($this->_sorts) === 0) {
            return;
        }

        $columns      = $this->_dataGrid->getActiveColumnsOrdered();
        $sorts        = $this->_sorts;
        $sortPosition = $this->_sortPositions;

        usort($this->_output, function ($a, $b) use ($columns, $sortPosition, $sorts) {
            foreach ($sortPosition as $colIndex) {
                $sort = $sorts[$colIndex];
                /** @var $sort\RBM\Datagrid\Data\Sort */
                /** @var $column\RBM\Datagrid\Column */
                $column = $columns[$colIndex];
                $valueA = $column->getSortData($a);
                $valueB = $column->getSortData($b);

                if ($valueA == $valueB) {
                    continue;
                }

                $arr = array($valueA, $valueB);

                $args = array_merge(array(&$arr), array($sort->getDirection(), $sort->getType()));
                call_user_func_array('array_multisort', $args);

                return ($arr[0] == $valueA) ? -1 : 1;
            }
            return 0;
        });
    }
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;
    }
1064891
public function getSortNext()
	{
		$defaultSort = $this->grid->getColumnDefaultSort($this->key);

		if ($this->sort == 'ASC') {
			return [$this->key => $defaultSort === 'DESC' ? FALSE : 'DESC'];
		} else if ($this->sort == 'DESC') {
			return [$this->key => $defaultSort === 'DESC' ? 'ASC' : FALSE];
		}

		return [$this->key => 'ASC'];
	}
598946
def sort(self, column, order=Qt.AscendingOrder):
        """"""
        reverse = (order==Qt.DescendingOrder)
        if column == 0:
            self.sizes = sort_against(self.sizes, self.keys, reverse)
            self.types = sort_against(self.types, self.keys, reverse)
            try:
                self.keys.sort(reverse=reverse)
            except:
                pass
        elif column == 1:
            self.keys[:self.rows_loaded] = sort_against(self.keys, self.types,
                                                        reverse)
            self.sizes = sort_against(self.sizes, self.types, reverse)
            try:
                self.types.sort(reverse=reverse)
            except:
                pass
        elif column == 2:
            self.keys[:self.rows_loaded] = sort_against(self.keys, self.sizes,
                                                        reverse)
            self.types = sort_against(self.types, self.sizes, reverse)
            try:
                self.sizes.sort(reverse=reverse)
            except:
                pass
        elif column == 3:
            values = [self._data[key] for key in self.keys]
            self.keys = sort_against(self.keys, values, reverse)
            self.sizes = sort_against(self.sizes, values, reverse)
            self.types = sort_against(self.types, values, reverse)
        self.beginResetModel()
        self.endResetModel()
20988
private function _getSortAnchor()
    {
        $result = '';

        /*
         * Plain Bootstrap with glyphicons
         */
        if ('resource-table::bootstrap' === $this->_viewName) {
            $result .= '<a href="'.$this->sortUrl().'" class="pull-right">';
            $glyphicon = 'glyphicon-sort';
            if ($this->sortActive()) {
                // Column is active - we can show proper icon
                $glyphicon = $this->sortDirection() === 'DESC' ? 'glyphicon-sort-by-attributes' : 'glyphicon-sort-by-attributes-alt';
            }
            $result .= '<i class="glyphicon '.$glyphicon.'"></i>';
            $result .= '</a>';
        }

        /*
         * Just simple table
         */
        if (!$result) {
            $result .= '<a href="'.$this->sortUrl().'" style="font-weight:'.($this->sortActive() ? 'bold' : 'normal').'">';
            $result .= $this->sortDirection() === 'DESC' ? '&#8595;' : '&#8593;';
            $result .= '</a>';
        }

        return $result;
    }
862201
def sortByColumn(self, index):
        """"""
        if self.sort_old == [None]:
            self.header_class.setSortIndicatorShown(True)
        sort_order = self.header_class.sortIndicatorOrder()
        self.sig_sort_by_column.emit()
        if not self.model().sort(index, sort_order):
            if len(self.sort_old) != 2:
                self.header_class.setSortIndicatorShown(False)
            else:
                self.header_class.setSortIndicator(self.sort_old[0],
                                                   self.sort_old[1])
            return
        self.sort_old = [index, self.header_class.sortIndicatorOrder()]
1350043
protected function getSortableColumns()
    {
        if ($this->sortableColumns !== null) {
            return $this->sortableColumns;
        }

        $columns = $this->getColumns();
        $sortable = array_filter($columns, function ($column) {
            return $column->sortable;
        });

        return $this->sortableColumns = $sortable;
    }