group the results by { class_name: [ids] } and save their sorted order
333770
def group_sorted_results(search_results)
      grouped_results = {}
      sort_order = {}
      search_results[:hits][:hits].each_with_index do |result, index|
        model = result[:_source][:model].to_sym
        model_id = result[:_source][:id]
        sort_order["#{model}_#{model_id}"] = index # save the sort order
        grouped_results[model] ||= []
        grouped_results[model] << model_id
      end
      [grouped_results, sort_order]
    end
895512
function processResults(indexes) {
    // Contains all the information
    let info = {};
    // Process all the indexes
    for (let i = 0; i < indexes.length; i++) {
      const index = indexes[i];
      // Let's unpack the object
      info[index.name] = [];
      for (let name in index.key) {
        info[index.name].push([name, index.key[name]]);
      }
    }

    return info;
  }
460943
def sort_by_name(self):
        """"""
        super(JSSObjectList, self).sort(key=lambda k: k.name)
476413
def csort(objs, key):
    """"""
    idxs = dict((obj, i) for (i, obj) in enumerate(objs))
    return sorted(objs, key=lambda obj: (key(obj), idxs[obj]))
260293
def groupby(self, by=None, **kwargs):
        
        if by is None:
            by = self.plydata_groups

        # Turn off sorting by groups messes with some verbs
        if 'sort' not in kwargs:
            kwargs['sort'] = False

        return super().groupby(by, **kwargs)
1261542
def format_results(self, results, request):
        
        self.prepare_sorting_fields()
        if self._sorting_fields:
            results = self.sort_results(results)

        if request.accepted_renderer.format == 'html':
            # Makes the the results available to the template context by transforming to a dict
            results = {'data': results}

        return results
836198
function groupBy(keySelector, elementSelector, resultSelector, keyComparator) {
                            __assertFunction(keySelector);
                            __assertFunction(elementSelector);
                            __assert(__isUndefined(resultSelector) || __isFunction(resultSelector), 'resultSelector must be undefined or function!');
                            __assertFunction(keyComparator);
                            var groups = new Map();
                            var result = void 0;
                            var _iteratorNormalCompletion15 = true;
                            var _didIteratorError15 = false;
                            var _iteratorError15 = undefined;

                            try {
                                for (var _iterator15 = self[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {
                                    var val = _step15.value;

                                    // Instead of checking groups.has we use our custom function since we want to treat some keys as equal even if they aren't for the Map
                                    var key = __Collection.__getEqualKey(groups, keySelector(val), keyComparator);
                                    var elem = elementSelector(val);
                                    if (groups.has(key)) {
                                        groups.get(key).push(elem);
                                    } else {
                                        groups.set(key, [elem]);
                                    }
                                }
                            } catch (err) {
                                _didIteratorError15 = true;
                                _iteratorError15 = err;
                            } finally {
                                try {
                                    if (!_iteratorNormalCompletion15 && _iterator15.return) {
                                        _iterator15.return();
                                    }
                                } finally {
                                    if (_didIteratorError15) {
                                        throw _iteratorError15;
                                    }
                                }
                            }

                            if (resultSelector) {
                                // If we want to select the final result with the resultSelector, we use the built-in Select function and retrieve a new Collection
                                result = __Collection.from(groups).select(function (g) {
                                    return resultSelector.apply(undefined, _toConsumableArray(g));
                                });
                            } else {
                                // our result is just the groups -> return the Map
                                result = groups;
                            }
                            return result;
                        }
821156
function( json, field, params, callback ){
    field = field || 'id';
    var objectIds = [],
      props;

    if (params.orderByFields && params.orderByFields !== ''){
      var fld = params.orderByFields.split(' ');
      var order = params.orderByFields;
      if (fld[fld.length-1] == 'DESC'){
        order = '-' + params.orderByFields;
      }
      json.features = this.orderBy(json.features, params.orderByFields, order);
    }

    json.features.forEach( function(f){
      props = f.attributes || f.properties;
      objectIds.push( props[ field ] );
    });

    callback( null, {
      objectIdField: field,
      objectIds: objectIds
    });
  }
97998
def _pull_query_results(resultset):
    '''
    
    '''
    _results = collections.defaultdict(lambda: {})
    for _header, _values in resultset.items():
        _header, _group_tags = _header
        if _group_tags:
            _results[_header][salt.utils.json.dumps(_group_tags)] = [_value for _value in _values]
        else:
            _results[_header] = [_value for _value in _values]
    return dict(sorted(_results.items()))
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
343710
def __process_results(results):
    
    if 'no match' in results and 'returning 0 elements' in results:
        return []

    result_list = []

    # Splts the result and cuts first and last dataset which are comments
    split = results.split(sep='\n\n')[1:-1]

    for entry in split:
        entry_dict = {}
        for value in entry.split('\n'):
            if len(value) < 1:
                continue
            (desc, val) = value.split(': ')
            entry_dict[desc.replace('-', '')] = val.strip(' ')
        result_list.append(entry_dict)
    return result_list
22133
def get_group_by_class(self, definition):
        
        group_by = definition["group"]
        series = definition["series"]
        if "formatter" in definition:
            formatter = {group_by: definition["formatter"]}
        else:
            formatter = {}
        return self.ProcessClass([group_by], series, formatter)
1154034
def _callbacks_grouped_by_name(self):
        """"""
        callbacks, names_set_by_user = OrderedDict(), set()
        for name, cb, named_by_user in self._yield_callbacks():
            if named_by_user:
                names_set_by_user.add(name)
            callbacks[name] = callbacks.get(name, []) + [cb]
        return callbacks, names_set_by_user
1255055
def reorder(things, ids)
      ordered_things = []
      ids.each do |id|
        thing = things.find{ |t| t.id.to_s == id.to_s }
        ordered_things |= [thing] if thing
      end
      ordered_things
    end
1246654
def items(cls):
        
        items = [(value.name, key) for key, value in cls.values.items()]
        return sorted(items, key=lambda x: x[1])
871416
def _save_group(self, group_id, result):
        """"""
        self.TaskSetModel._default_manager.store_result(group_id, result)
        return result
93835
def save_results(self, path='.'):
        """"""
        with open(path, 'wb') as f:
            pickle.dump(self.results, f)