General sort filter - sorts by either attribute or key.
9127
def sort_by(items, attr):
    
    def key_func(item):
        try:
            return getattr(item, attr)
        except AttributeError:
            try:
                return item[attr]
            except TypeError:
                getattr(item, attr)  # Reraise AttributeError
    return sorted(items, key=key_func)
615723
def _filter_parameters(parameters):
    """"""
    if not parameters:
        return None
    return OrderedDict(
        (param, value) for param, value in six.iteritems(parameters) if param not in IGNORED_PARAMS
    )
973011
def sort(key)
      @items = @items.sort_by{|i| i[key] }
    rescue NoMethodError => e
      Smoke.log.info "You're trying to sort by \"#{key}\" but it does not exist in your item set"
    end
930247
function sortAttrs(attrs) {
    return attrs.sort(function (a, b) {
        if (a.name < b.name) {
            return -1;
        } else if (a.name > b.name) {
            return 1;
        } else if (a.value < b.value) {
            return -1;
        } else if (a.value > b.value) {
            return 1;
        }

        return 0;
    });
}
58572
def _filter_attrs(attrs, ignored_attrs):
    
    return dict((k, v) for k, v in attrs.items() if k not in ignored_attrs)
1045301
function sortByAttributeNameComparitor(a,b) {
    if (a.attributes.name < b.attributes.name)
      return -1;
    if (a.attributes.name > b.attributes.name)
      return 1;
    
    return 0;
  }
597095
def _filter_attributes(self, keyset):
        
        filtered = self._filter_keys(self.to_dict(), keyset)
        return Language.make(**filtered)
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
735237
def filter(self, table, group_types, filter_string):
        """"""
        query = filter_string.lower()
        return [group_type for group_type in group_types
                if query in group_type.name.lower()]
470568
def filter_by(self, **filters):
        ''' '''
        for name, value in filters.items():
            self.filter(resolve_name(self.type, name) == value)
        return self
875794
def matching_attributes?(attribute, filter)
      attribute.to_s.downcase == filter.to_s.delete('_').downcase
    end
991908
def sort(self, cmp=None, key=None, reverse=False):
        """"""
        if not key and self._keys:
            key = self.KeyValue
        super(CliTable, self).sort(cmp=cmp, key=key, reverse=reverse)
1129497
def _filter_optional_keys(self, data):
        """"""
        for filter_key, filter_value in (self._optional_filters or {}).items():
            data_value = data.get(filter_key)
            LOG.debug(
                'optional keys filter %s: %s (%s)',
                filter_key, filter_value, data_value
            )
            if data_value is None or data_value != filter_value:
                LOG.debug(
                    'optional keys filter rejecting %s: %s (%s)',
                    filter_key, filter_value, data_value
                )
                return False
        return True
495081
def filter_dict(d, keys):
    
    return {k: v for k, v in d.items() if k in keys}
1354473
def sort_func(self, key):
        """"""
        if key == self._KEYS.TIME:
            return 'aaa'
        if key == self._KEYS.DATA:
            return 'zzy'
        if key == self._KEYS.SOURCE:
            return 'zzz'
        return key
137665
def sortBy(self, *args):
        ''''''
        criteria = ['seeds', 'size']
        for k in args:
            if k in criteria:
                self.results = sorted(
                    self.results, key=attrgetter(k), reverse=True)
        return self
687082
protected function sortFilters()
    {
        usort($this->filters, function (FilterInterface $a, FilterInterface $b) {
            $a = $a->getPriority();
            $b = $b->getPriority();

            if ($a == $b) {
                return 0;
            }

            return $a < $b ? -1 : 1;
        });

        $this->sorted = true;
    }