Sort collectors by definition identifier.
344370
def sort_collectors!
      @sorted_collectors = {}

      tmp = @collectors.sort_by { |_klass, definition| definition.position }
      tmp.each { |_k, v| @sorted_collectors[v.identifier.to_sym] = v }
    end
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)
549385
private static void sortAnonymous(List<IType> anonymous, IType anonType) {
        SourceOffsetComparator sourceComparator = new SourceOffsetComparator();

        final AnonymClassComparator classComparator = new AnonymClassComparator(anonType, sourceComparator);
        Collections.sort(anonymous, classComparator);

//        if (Reporter.DEBUG) {
//            debugCompilePrio(classComparator);
//        }
    }
786519
def priority(s):
    """"""
    # REZ: Previously this value was calculated in place many times which is
    #      expensive.  Do it once early.
    # REZ: Changed this to output a list, so that can nicely sort "validate"
    #      items by the sub-priority of their schema
    type_of_s = type(s)
    if type_of_s in (list, tuple, set, frozenset):
        return [ITERABLE]
    if type_of_s is dict:
        return [DICT]
    if issubclass(type_of_s, type):
        return [TYPE]
    if hasattr(s, 'validate'):
        p = [VALIDATOR]
        if hasattr(s, "_schema"):
            p.extend(priority(s._schema))
        return p
    if callable(s):
        return [CALLABLE]
    else:
        return [COMPARABLE]
1131693
def _get_names(self, collector):
        """"""
        desc_func = None
        # If there's a describe function, use it.
        try:
            desc_func = collector.describe
        except AttributeError:
            pass
        # Otherwise, if auto describe is enabled use the collect function.
        if not desc_func and self._auto_describe:
            desc_func = collector.collect

        if not desc_func:
            return []

        result = []
        type_suffixes = {
            'counter': ['_total', '_created'],
            'summary': ['', '_sum', '_count', '_created'],
            'histogram': ['_bucket', '_sum', '_count', '_created'],
            'gaugehistogram': ['_bucket', '_gsum', '_gcount'],
            'info': ['_info'],
        }
        for metric in desc_func():
            for suffix in type_suffixes.get(metric.type, ['']):
                result.append(metric.name + suffix)
        return result
1246654
def items(cls):
        
        items = [(value.name, key) for key, value in cls.values.items()]
        return sorted(items, key=lambda x: x[1])
41079
public static <T> Collector<T, ?, Optional<Long>> denseRank(T value, Comparator<? super T> comparator) {
        return denseRankBy(value, t -> t, comparator);
    }
357700
def t_IDENTIFIER(self, t):
        '

        if t.value in THRIFT_KEYWORDS:
            # Not an identifier after all.
            t.type = t.value.upper()

        return t
513161
def _collection(self):
        
        old_sort_limits_and_len_mode = None if self._sort_limits is None else self._sort_limits.copy(), self._len_mode
        old_sorts = None if self._sort is None else self._sort.copy(),\
                    None if self._sort_by_sortedset is None else self._sort_by_sortedset.copy()
        try:
            if self.stored_key and not self._stored_len:
                if self._len_mode:
                    self._len = 0
                    self._len_mode = False
                self._sort_limits = {}
                return []

            # Manage sort desc added by original `__getitem__` when we sort by score
            if self._sort_by_sortedset and self._sort and self._sort.get('desc'):
                self._sort = None
                self._sort_by_sortedset['desc'] = not self._sort_by_sortedset.get('desc', False)

            return super(ExtendedCollectionManager, self)._collection
        finally:
            self._sort_limits, self._len_mode = old_sort_limits_and_len_mode
            self._sort, self._sort_by_sortedset = old_sorts
813622
def sort_generators(self):
        
        self.generators.sort(key=lambda gn: gn.bus._i)
1206285
def discardID(self, idVal):
        
        for i in self:
            if i.id == idVal:
                self._collection.discard(i)
                return
227619
public function sortFieldDefinitions()
    {
        usort(
            $this->fieldDefinitionsData,
            function ($a, $b) {
                if ($a->fieldDefinition->position === $b->fieldDefinition->position) {
                    // The identifiers can never be the same
                    return $a->fieldDefinition->identifier < $b->fieldDefinition->identifier ? -1 : 1;
                }

                return $a->fieldDefinition->position < $b->fieldDefinition->position ? -1 : 1;
            }
        );
    }
1220848
def _get_converter_type(identifier):
    """"""
    if isinstance(identifier, str):
        return ConverterType[identifier]
    if isinstance(identifier, ConverterType):
        return identifier
    return ConverterType(identifier)
762133
private ArrayList handleDependentCollections(Identity oid, Object obj,
            Object[] origCollections, Object[] newCollections,
            Object[] newCollectionsOfObjects)
            throws LockingException
    {
        ClassDescriptor mif = _pb.getClassDescriptor(obj.getClass());
        Collection colDescs = mif.getCollectionDescriptors();
        ArrayList newObjects = new ArrayList();
        int count = 0;

        for (Iterator it = colDescs.iterator(); it.hasNext(); count++)
        {
            CollectionDescriptor cds = (CollectionDescriptor) it.next();

            if (cds.getOtmDependent())
            {
                ArrayList origList = (origCollections == null ? null
                                        : (ArrayList) origCollections[count]);
                ArrayList newList = (ArrayList) newCollections[count];

                if (origList != null)
                {
                    for (Iterator it2 = origList.iterator(); it2.hasNext(); )
                    {
                        Identity origOid = (Identity) it2.next();

                        if ((newList == null) || !newList.contains(origOid))
                        {
                            markDelete(origOid, oid, true);
                        }
                    }
                }

                if (newList != null)
                {
                    int countElem = 0;
                    for (Iterator it2 = newList.iterator(); it2.hasNext(); countElem++)
                    {
                        Identity newOid = (Identity) it2.next();

                        if ((origList == null) || !origList.contains(newOid))
                        {
                            ContextEntry entry = (ContextEntry) _objects.get(newOid);

                            if (entry == null)
                            {
                                ArrayList relCol = (ArrayList)
                                        newCollectionsOfObjects[count];
                                Object relObj = relCol.get(countElem);
                                insertInternal(newOid, relObj, LockType.WRITE_LOCK,
                                               true, null, new Stack());
                                newObjects.add(newOid);
                            }
                        }
                    }
                }
            }
        }

        return newObjects;
    }
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)
1046812
def find(self, name):
        
        collectors = self.get_collectors()

        for collector in collectors:
            if name.lower() == collector['name'].lower():
                self.collector_id = collector['id']
                return collector

        return {'status': 'No results found.'}
1008170
public function identifiers()
    {
        if (!$this->_identifiers) {
            $this->_identifiers = new IdentifierCollection($this->getConfig('identifiers'));
        }

        return $this->_identifiers;
    }