Takes a list of dicts each of which has an '@id' key,
    sorts the elements in the list by the value of the @id key.
    Assumes that @id is unique or the dicts have a meaningul < operator
356479
def _inplace_sort_by_id(unsorted_list):
    
    if not isinstance(unsorted_list, list):
        return
    sorted_list = [(i.get('@id'), i) for i in unsorted_list]
    sorted_list.sort()
    del unsorted_list[:]
    unsorted_list.extend([i[1] for i in sorted_list])
733960
def keys(self, key=None, reverse=False):
        """"""
        ks = sorted(list(dict.keys(self)), key=key, reverse=reverse)
        return ks
786990
def _sorted_keys_items(dobj):
    """"""
    keys = sorted(dobj.keys())
    for key in keys:
        yield key, dobj[key]
919107
def clean_dict_keys(d):
    
    new_d = {}
    for (k, v) in d.iteritems():
        new_d[str(k)] = v
    return new_d
1012675
function uniqueArray(src, key, sort) {
    var results = [];
    var values = [];
    var i = 0;

    while (i < src.length) {
        var val = key ? src[i][key] : src[i];
        if (inArray(values, val) < 0) {
            results.push(src[i]);
        }
        values[i] = val;
        i++;
    }

    if (sort) {
        if (!key) {
            results = results.sort();
        } else {
            results = results.sort(function sortUniqueArray(a, b) {
                return a[key] > b[key];
            });
        }
    }

    return results;
}
1287950
def in_bulk(self, id_list):
        
        if not id_list:
            return {}
        qs = self._clone()
        qs.add_filter(('pk__in', id_list))
        qs._clear_ordering(force_empty=True)
        return dict([(obj._get_pk_val(), obj) for obj in qs])
783521
def constant_tuples_ordered_by_id(self):
        
        return sorted(list(self.constant_tuple_dict), key=lambda constant_tuple: constant_tuple.constant.id)
528585
def sort(self, **kwargs):
        
        query = {}
        for field in kwargs:
            query[field] = kwargs[field]
        self._q.append({'$sort': query})
        return self
979033
def unique_list_dicts(dlist, key):
    

    return list(dict((val[key], val) for val in dlist).values())
216491
def filter_dict(iterable, keys):
  
  if type(keys) is not list:
    keys = [keys]
  for i in iterable:
    try:
      d = {}
      for a in keys:
        try:
          d[a] = i[a]
        except KeyError:
          pass
      if d != {}:
        yield d
    except Exception:
      pass
195647
def _ordered_keys(dict_):
        
        return isinstance(dict_, OrderedDict) and dict_.keys() or \
               dict_ and sorted(dict_.keys()) or []
76255
def sort_by_attr!(objects, order = { locale: :asc, key: :asc })
      order_keys = order.keys
      objects.sort! do |a, b|
        by = order_keys.detect { |k| a[k] != b[k] }
        order[by] == :desc ? b[by] <=> a[by] : a[by] <=> b[by]
      end
      objects
    end
423434
def filter_ids(self):
        
        return self._sorted_ingredients([
            d.id for d in self.values() if isinstance(d, Filter)
        ])
291806
def order_by(self, key):
        
        if key is None:
            raise NullArgumentError(u"No key for sorting given")
        kf = [OrderingDirection(key, reverse=False)]
        return SortedEnumerable(key_funcs=kf, data=self._data)
1329667
def clean_dict(d, test=lambda v: v):
    
    return {k: v for k, v in d.items() if test(v)}
206599
def map_sorted(hash)
      hash.keys
          .sort_by(&:to_sym)
          .map { |k| yield k, hash[k] }
    end
770860
def index(self, key):
        
        if isinstance(key, str):
            for idx, (item, quality) in enumerate(self):
                if self._value_matches(key, item):
                    return idx
            raise ValueError(key)
        return list.index(self, key)