Overridable method for available sortable fields
541006
def sortable_fields_for(model)
      if model.respond_to?(:sortable_fields)
        model.sortable_fields.map(&:to_sym)
      elsif model.respond_to?(:column_names)
        model.column_names.map(&:to_sym)
      else
        []
      end
    end
1168820
public PushOptions sort(final String field, final int direction) {
        if (sort != null) {
            throw new IllegalStateException("sortDocument can not be set if sort already is");
        }
        if (sortDocument == null) {
            sortDocument = new BasicDBObject();
        }
        sortDocument.put(field, direction);
        return this;
    }
888768
def sorted_by_field(issues, field='closed_at', reverse=False):
    """"""
    return sorted(issues, key = lambda i:i[field], reverse=reverse)
593337
def manageable_sortable(column, title = nil, options = {})
      title ||= column.titleize

      if respond_to?(:sort_column) && respond_to?(:sort_direction)
        css_class = column && sort_column && column.to_sym == sort_column.to_sym ? "sort_#{sort_direction}" : nil
        direction = column && sort_column && column.to_sym == sort_column.to_sym && sort_direction == "asc" ? "desc" : "asc"
        options[:class] = [options[:class], css_class].compact.join(" ")

        link_to title, params.merge(:sort => column, :direction => direction, :page => nil), options
      else
        title
      end
    end
755188
def prepare_sorting_fields(self):
        
        if self.sorting_parameter_name in self.request.query_params:
            # Extract sorting parameter from query string
            self._sorting_fields = [
                _.strip() for _ in self.request.query_params.get(self.sorting_parameter_name).split(',')
            ]

        if self._sorting_fields:
            # Create a list of sorting parameters. Each parameter is a tuple: (field:str, descending:bool)
            self._sorting_fields = [
                (self.sorting_fields_map.get(field.lstrip('-'), field.lstrip('-')), field[0] == '-')
                for field in self._sorting_fields
            ]
436631
public static String getSortableFieldFromClass( Class<?> clazz ) {

        /** See if the fieldName is in the field listStream already.
         * We keep a hash-map cache.
         * */
        String fieldName = getSortableField( clazz );

        /**
         * Not found in cache.
         */
        if ( fieldName == null ) {

            /* See if we have this sortable field and look for string first. */
            for ( String name : fieldSortNames ) {
                if ( classHasStringField( clazz, name ) ) {
                    fieldName = name;
                    break;
                }
            }

            /*
             Now see if we can find one of our predefined suffixes.
             */
            if ( fieldName == null ) {
                for ( String name : fieldSortNamesSuffixes ) {
                    fieldName = getFirstStringFieldNameEndsWithFromClass( clazz, name );
                    if ( fieldName != null ) {
                        break;
                    }
                }
            }

            /**
             * Ok. We still did not find it so give us the first comparable or
             * primitive that we can find.
             */
            if ( fieldName == null ) {
                fieldName = getFirstComparableOrPrimitiveFromClass( clazz );
            }

            /* We could not find a sortable field. */
            if ( fieldName == null ) {
                setSortableField( clazz, "NOT FOUND" );
                Exceptions.die("Could not find a sortable field for type " + clazz);

            }

            /* We found a sortable field. */
            setSortableField( clazz, fieldName );
        }
        return fieldName;

    }
1300871
def options(cls):
        """"""
        return sorted((value, name) for (name, value) in cls.__dict__.items() if not name.startswith('__'))
1221330
function(field,sortType){
			if(this.gridComp.options.showTree){
				this.treeSortRows(field,sortType);
			}else{
				this.basicSortRows(field,sortType);
			}
			this.gridComp.eidtRowIndex = -1;
		}
1173706
function sort(type) {
  if (!~SORT_TYPES.indexOf(type)) {
    throw new FieldError('Sorting type can be ' + SORT_TYPES.join(' or '))
  }

  return {
    type: type
  }
}
512603
function(options) {
	   inputEx.ListField.superclass.setOptions.call(this, options);
	   
	   this.options.className = options.className ? options.className : 'inputEx-Field inputEx-ListField';
	   
	   this.options.sortable = lang.isUndefined(options.sortable) ? false : options.sortable;
	   this.options.elementType = options.elementType || {type: 'string'};
	   this.options.useButtons = lang.isUndefined(options.useButtons) ? false : options.useButtons;
	   this.options.unique = lang.isUndefined(options.unique) ? false : options.unique;
	   
	   this.options.listAddLabel = options.listAddLabel || inputEx.messages.listAddLink;
	   this.options.listRemoveLabel = options.listRemoveLabel || inputEx.messages.listRemoveLink;
	   
	   this.options.maxItems = options.maxItems;
	   this.options.minItems = options.minItems;
	}
11713
def sort=(sort)
      validator = EnumAttributeValidator.new('String', ["COUNT", "INDEX"])
      unless validator.valid?(sort)
        fail ArgumentError, "invalid value for 'sort', must be one of #{validator.allowable_values}."
      end
      @sort = sort
    end
8367
def visit_field(rec, field, op):
    # type: (Any, Iterable, Union[Callable[..., Any], partial[Any]]) -> None
    """"""

    if isinstance(rec, MutableMapping):
        if field in rec:
            rec[field] = op(rec[field])
        for d in rec:
            visit_field(rec[d], field, op)
    if isinstance(rec, MutableSequence):
        for d in rec:
            visit_field(d, field, op)
1059348
function SortOrderComparator(sortOrder, options) {
        this.sortOrder = sortOrder;
        this.options = {
            casesensitive: false
        };
        if (options) {
            _.extend(this.options, options);
        }
        this.expressions = new Array(sortOrder.sortFields.length);
        for (var i = 0; i < this.expressions.length; ++i) {
            this.expressions[i] = new JsonPath_1.JsonPath(sortOrder.sortFields[i].name);
        }
    }
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)
  };
}
382058
def custom_sort(enumerable)
      sorted_array = enumerable.sort_by do |key, _|
        key.sub(/^the\s*/i, '').downcase
      end

      # sort_by() returns an array when called on hashes.
      if enumerable.kind_of?(Hash)
        # Rebuild the hash.
        sorted_hash = {}
        sorted_array.each { |item| sorted_hash[item[0]] = item[1] }
        sorted_hash
      else
        sorted_array
      end
    end
1016102
function(options) {
      options || (options = {});
      if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
      var boundComparator = _.bind(this.comparator, this);
      if (this.comparator.length == 1) {
        this.models = this.sortBy(boundComparator);
      } else {
        this.models.sort(boundComparator);
      }
      if (!options.silent) this.trigger('reset', this, options);
      return this;
    }
980689
def sort
      objects.values.each do |object|
        SORTABLE_ITEMS.select { |key| object.has_key?(key) }.each do |key|
          object[key].sort_by!(&method(:comparator))
        end
      end
      project
    end