Allow user defined fields to sort on in addition to introspected fields
4446
def search_on(column_source, methods)
      Array(methods).each do |method_name|
        join column_source
        self.searches += [{column_source: column_source.to_s, method_name: method_name.to_s}]
      end
    end
550485
def yank_fields_from_attrs(attrs, _as=None, sort=True):
    
    fields_with_names = []
    for attname, value in list(attrs.items()):
        field = get_field_as(value, _as)
        if not field:
            continue
        fields_with_names.append((attname, field))

    if sort:
        fields_with_names = sorted(fields_with_names, key=lambda f: f[1])
    return OrderedDict(fields_with_names)
463576
def _addSortParam(self, field, order=''):
		""""""

		if order != '':
			validSortOrders = {
				'ascend':'ascend',
				'ascending':'ascend',
				'<':'ascend',
				'descend':'descend',
				'descending':'descend',
				'>':'descend'
			}

			if not string.lower(order) in validSortOrders.keys():
				raise FMError, 'Invalid sort order for "' + field + '"'

		self._sortParams.append(
			[field, validSortOrders[string.lower(order)]]
		)
40361
function getUserFields(selector, sort) {
  var selectorFields = Object.keys(selector);
  var sortFields = sort? sort.map(getKey) : [];
  var userFields;
  if (selectorFields.length >= sortFields.length) {
    userFields = selectorFields;
  } else {
    userFields = sortFields;
  }

  if (sortFields.length === 0) {
    return {
      fields: userFields
    };
  }

  // sort according to the user's preferred sorting
  userFields = userFields.sort(function (left, right) {
    var leftIdx = sortFields.indexOf(left);
    if (leftIdx === -1) {
      leftIdx = Number.MAX_VALUE;
    }
    var rightIdx = sortFields.indexOf(right);
    if (rightIdx === -1) {
      rightIdx = Number.MAX_VALUE;
    }
    return leftIdx < rightIdx ? -1 : leftIdx > rightIdx ? 1 : 0;
  });

  return {
    fields: userFields,
    sortOrder: sort.map(getKey)
  };
}
234347
def sorted_fields(cls):
        
        for property in sorted(cls.fields(), key=cls._field_sort_name):
            yield property
1021398
def _normalize_sort_SQL(self, field_name, field_vals, sort_dir_str):
        
        fvi = None
        if sort_dir_str == 'ASC':
            fvi = (t for t in enumerate(field_vals)) 

        else:
            fvi = (t for t in enumerate(reversed(field_vals))) 

        query_sort_str = ['  CASE {}'.format(self._normalize_name(field_name))]
        query_args = []
        for i, v in fvi:
            query_sort_str.append('    WHEN {} THEN {}'.format(self.val_placeholder, i))
            query_args.append(v)

        query_sort_str.append('  END')
        query_sort_str = "\n".join(query_sort_str)
        return query_sort_str, query_args
202645
def fields_for(*args, &block)
      if search_obj = args.find { |arg| arg.is_a?(Searchlogic::Search) }
        args.unshift(:search) if args.first == search_obj
        options = args.extract_options!
        if !options[:skip_order_field]
          concat(content_tag("div", hidden_field_tag("#{args.first}[order]", search_obj.order), :style => "display: inline"))
        end
        args << options
        super
      else
        super
      end
    end
528585
def sort(self, **kwargs):
        
        query = {}
        for field in kwargs:
            query[field] = kwargs[field]
        self._q.append({'$sort': query})
        return self
739843
def __apply_nested_option(self, option_name, field_names, set_operation):
        """"""
        # Split nested field names on the first dot.
        nested_fields = [name.split('.', 1) for name in field_names if '.' in name]
        # Partition the nested field names by parent field.
        nested_options = defaultdict(list)
        for parent, nested_names in nested_fields:
            nested_options[parent].append(nested_names)
        # Apply the nested field options.
        for key, options in iter(nested_options.items()):
            new_options = self.set_class(options)
            original_options = getattr(self.declared_fields[key], option_name, ())
            if original_options:
                if set_operation == 'union':
                    new_options |= self.set_class(original_options)
                if set_operation == 'intersection':
                    new_options &= self.set_class(original_options)
            setattr(self.declared_fields[key], option_name, new_options)
498451
private void processFields() {
    List<Field> fields = IntrospectionUtils.getPersistableFields(embeddableClass);
    for (Field field : fields) {
      if (field.isAnnotationPresent(Embedded.class)) {
        processEmbeddedField(field);
      } else {
        processSimpleField(field);
      }
    }
  }
1310167
function orderAndSort(sortConf) {
    return {
        sortFieldName: sortConf.sortBy,
        sortDesc: sortConf.sortAsc === undefined ? false : !sortConf.sortAsc
    };
}
702830
def sort_field=(sort_field)
      validator = EnumAttributeValidator.new('String', ["DEFAULT", "CREATED_AT"])
      unless validator.valid?(sort_field)
        fail ArgumentError, "invalid value for 'sort_field', must be one of #{validator.allowable_values}."
      end
      @sort_field = sort_field
    end
227619
public function sortFieldDefinitions()
    {
        usort(
            $this->fieldDefinitionsData,
            function ($a, $b) {
                if ($a->fieldDefinition->position === $b->fieldDefinition->position) {
                    // The identifiers can never be the same
                    return $a->fieldDefinition->identifier < $b->fieldDefinition->identifier ? -1 : 1;
                }

                return $a->fieldDefinition->position < $b->fieldDefinition->position ? -1 : 1;
            }
        );
    }
947435
def validate_sort_fields(self):
        
        sort_fields = ','.join(self.options.sort_fields)
        if sort_fields == '*':
            sort_fields = self.get_output_fields()

        return formatting.validate_sort_fields(sort_fields or config.sort_fields)
1221330
function(field,sortType){
			if(this.gridComp.options.showTree){
				this.treeSortRows(field,sortType);
			}else{
				this.basicSortRows(field,sortType);
			}
			this.gridComp.eidtRowIndex = -1;
		}
1316881
def _prepare_sort_options(self, has_pk):
        
        sort_options = super(ExtendedCollectionManager, self)._prepare_sort_options(has_pk)

        if self._values:
            # if we asked for values, we have to use the redis 'sort'
            # command, which is able to return other fields.
            if not sort_options:
                sort_options = {}
            sort_options['get'] = self._values['fields']['keys']

        if self._sort_by_sortedset_after:
            for key in ('get', 'store'):
                if key in self._sort_by_sortedset:
                    del self._sort_by_sortedset[key]
            if sort_options and (not has_pk or self._want_score_value):
                for key in ('get', 'store'):
                    if key in sort_options:
                        self._sort_by_sortedset[key] = sort_options.pop(key)
            if not sort_options:
                sort_options = None
        return sort_options
164316
def _nice_fieldnames(all_columns, index_columns):
    ""
    non_index_columns = set(all_columns).difference(index_columns)
    return index_columns + sorted(non_index_columns)