Use this method to sort by price, distance, upcoming viewing or date using the SortType object.
        :param sort_by:
        :return:
492317
def set_sort_by(self, sort_by):
        
        if not isinstance(sort_by, SortType):
            raise DaftException("sort_by should be an instance of SortType.")

        self._sort_by = str(sort_by)
1350777
def get_sort_on(allowed_indexes=None):
    
    sort_on = get("sort_on")
    if allowed_indexes and sort_on not in allowed_indexes:
        logger.warn("Index '{}' is not in allowed_indexes".format(sort_on))
        return None
    return sort_on
168128
def sort(self, callback=None):
        
        items = self.items

        if callback:
            return self.__class__(sorted(items, key=callback))
        else:
            return self.__class__(sorted(items))
697246
def by_pattern(self,
                   pattern,
                   zipcode_type=ZipcodeType.Standard,
                   sort_by=SimpleZipcode.zipcode.name,
                   ascending=True,
                   returns=DEFAULT_LIMIT):
        
        return self.query(
            pattern=pattern,
            sort_by=sort_by, zipcode_type=zipcode_type,
            ascending=ascending, returns=returns,
        )
1143878
def sort(transactions):
    
    return transactions.sort(key=lambda x: datetime.datetime.strptime(x.split(':')[0], '%Y-%m-%d'))[:]
1301230
def order(types) #:nodoc:
      types.map {|type| AcceptMediaType.new(type) }.reverse.sort.reverse.select {|type| type.valid? }.map {|type| type.range }
    end
956071
def sort_model(self, *args, **kwargs):
        
        self.proxy.sort(17)  # sort the identifier
        self.proxy.sort(2)  # sort the element
        self.proxy.sort(1)  # sort the elementgrp
        self.proxy.sort(0)
1340013
def sales_for_time_period(from_date, to_date):
    
    sales = Order.objects.filter(
        Q(payment_date__lte=to_date) & Q(payment_date__gte=from_date)
    ).exclude(status=Order.CANCELLED)

    return sales
362252
def cost_type(self, cost_type):
        
        allowed_values = ["orderSubtotal", "weight"]
        if cost_type is not None and cost_type not in allowed_values:
            raise ValueError(
                "Invalid value for `cost_type` ({0}), must be one of {1}"
                .format(cost_type, allowed_values)
            )

        self._cost_type = cost_type
824203
def by_prefix(self,
                  prefix,
                  zipcode_type=ZipcodeType.Standard,
                  sort_by=SimpleZipcode.zipcode.name,
                  ascending=True,
                  returns=DEFAULT_LIMIT):
        
        return self.query(
            prefix=prefix,
            sort_by=sort_by, zipcode_type=zipcode_type,
            ascending=ascending, returns=returns,
        )
579813
public void sortTypes(String sortParams) {

        List<CmsResourceTypeBean> types = getSearchTypes();
        SortParams sort = SortParams.valueOf(sortParams);
        switch (sort) {
            case title_asc:
                Collections.sort(types, new CmsComparatorTitle(true));
                break;
            case title_desc:
                Collections.sort(types, new CmsComparatorTitle(false));
                break;
            case type_asc:
                Collections.sort(types, new CmsComparatorType(true));
                break;
            case type_desc:
                Collections.sort(types, new CmsComparatorType(false));
                break;
            case dateLastModified_asc:
            case dateLastModified_desc:
            case path_asc:
            case path_desc:
            case tree:
            default:
                // not supported
                return;
        }
        m_handler.onUpdateTypes(types, m_searchObject.getTypes());
    }
500862
function sortByDate(a, b) {
    return new Date(a.added).getTime() - new Date(b.added).getTime();
  }
167575
def prj_view_atype(self, *args, **kwargs):
        
        if not self.cur_prj:
            return
        i = self.prj_atype_tablev.currentIndex()
        item = i.internalPointer()
        if item:
            atype = item.internal_data()
            self.view_atype(atype)
295950
def sorts_by_method?
      @clauses.any? { |sorting| sorting[0].sort.is_a?(Hash) && sorting[0].sort.key?(:method) }
    end
96261
def _type_priority(ifo, ftype, trend=None):
    
    # if looking for a trend channel, prioritise the matching type
    for trendname, trend_regex in [
            ('m-trend', MINUTE_TREND_TYPE),
            ('s-trend', SECOND_TREND_TYPE),
    ]:
        if trend == trendname and trend_regex.match(ftype):
            return 0, len(ftype)

    # otherwise rank this type according to priority
    for reg, prio in {
            HIGH_PRIORITY_TYPE: 1,
            re.compile(r'[A-Z]\d_C'): 6,
            LOW_PRIORITY_TYPE: 10,
            MINUTE_TREND_TYPE: 10,
            SECOND_TREND_TYPE: 10,
    }.items():
        if reg.search(ftype):
            return prio, len(ftype)

    return 5, len(ftype)
162946
def sortBy(self, val=None):
        
        if val is not None:
            if _(val).isString():
                return self._wrap(sorted(self.obj, key=lambda x,
                                  *args: x.get(val)))
            else:
                return self._wrap(sorted(self.obj, key=val))
        else:
            return self._wrap(sorted(self.obj))
221786
def sorted(self, fsort):
        '''
        
        '''
        if not self.params:
            self.params = dict()
        self.params['sort'] = fsort

        return self