Sort a list of elements that have priority attributes
503843
def prioSort(elements):
    """"""
    # Randomize the services before sorting so that equal priority
    # elements are load-balanced.
    random.shuffle(elements)

    prio_elems = [(getPriority(e), e) for e in elements]
    prio_elems.sort()
    sorted_elems = [s for (_, s) in prio_elems]
    return sorted_elems
901874
function sortRankedItems(a, b) {
  const aFirst = -1
  const bFirst = 1
  const {rank: aRank, index: aIndex, keyIndex: aKeyIndex} = a
  const {rank: bRank, index: bIndex, keyIndex: bKeyIndex} = b
  const same = aRank === bRank
  if (same) {
    if (aKeyIndex === bKeyIndex) {
      return aIndex < bIndex ? aFirst : bFirst
    } else {
      return aKeyIndex < bKeyIndex ? aFirst : bFirst
    }
  } else {
    return aRank > bRank ? aFirst : bFirst
  }
}
874337
private void sortCandidateList(ArrayList list) {
    java.util.Collections.sort(list, new java.util.Comparator() {
      public int compare(Object o1, Object o2) {
        // First sort, by score in index
        double scoreT = ( (Candidates) o1).getScore(),
            scoreU = ( (Candidates) o2).getScore();
        if (scoreU > scoreT) {
          return 1;
        }
        if (scoreU < scoreT) {
          return -1;
        }
        return 0;
      }
    }
    );
  }
528318
public static <T> List<T> sort(List<T> list, Comparator<? super T> comparator) {
        Collections.sort(list, comparator);
        return list;
    }
624164
protected Map<String, String> getElementAttributes() {
        // Preserve order of attributes
        Map<String, String> attrs = new HashMap<>();

        if (this.getPriority() != null) {
            attrs.put("priority", this.getPriority().toString());
        }
        if (this.getTimeout() != null) {
            attrs.put("timeout", this.getTimeout().toString());
        }

        return attrs;
    }
1226286
def order_by(self, order_attribute):
        '''  '''
        to_return = []
        for f in sorted(self.items, key=lambda i: getattr(i, order_attribute)):
            to_return.append(f)
        return to_return
135788
def prioSort(elements):
    """"""
    # Randomize the services before sorting so that equal priority
    # elements are load-balanced.
    random.shuffle(elements)

    sorted_elems = sorted(elements, key=getPriority)
    return sorted_elems
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))
329343
private int[] priority(int focus, IAtom[] atoms, int n) {
        int[] rank = new int[n];
        for (int i = 0; i < n; i++)
            rank[i] = i;
        for (int j = 1; j < n; j++) {
            int v = rank[j];
            int i = j - 1;
            while ((i >= 0) && hasPriority(focus, atomToIndex.get(atoms[v]), atomToIndex.get(atoms[rank[i]]))) {
                rank[i + 1] = rank[i--];
            }
            rank[i + 1] = v;
        }
        return rank;
    }
391984
def sorted(self, attrname, reverse=False):
        
        attrs = []
        for i, pseudo in self:
            try:
                a = getattr(pseudo, attrname)
            except AttributeError:
                a = np.inf
            attrs.append((i, a))

        # Sort attrs, and build new table with sorted pseudos.
        return self.__class__([self[a[0]] for a in sorted(attrs, key=lambda t: t[1], reverse=reverse)])
93044
def sort(input, property = nil)
      ary = InputIterator.new(input)

      return [] if ary.empty?

      if property.nil?
        ary.sort do |a, b|
          nil_safe_compare(a, b)
        end
      elsif ary.all? { |el| el.respond_to?(:[]) }
        begin
          ary.sort { |a, b| nil_safe_compare(a[property], b[property]) }
        rescue TypeError
          raise_property_error(property)
        end
      end
    end
320021
def list_order(f, attribute, options)
      if is_association?(f, attribute) && !options[:collection]
        begin
          options[:collection] = to_class(attribute).for_fae_index
        rescue NameError
          raise "Fae::MissingCollection: `#{attribute}` isn't an orderable class, define your order using the `collection` option."
        end
      end
    end
939238
def sort_input(input, property, order)
      input.map { |item| [item_property(item, property), item] }
        .sort! do |a_info, b_info|
          a_property = a_info.first
          b_property = b_info.first

          if !a_property.nil? && b_property.nil?
            - order
          elsif a_property.nil? && !b_property.nil?
            + order
          else
            a_property <=> b_property || a_property.to_s <=> b_property.to_s
          end
        end
        .map!(&:last)
    end
779444
def sort_by_z(self):
        """"""
        return self.__class__(sorted(self, key=lambda p: p.Z))
984664
def alphabetize_attributes(self):
        
        self.attributes.sort(key=lambda name: (name == self.class_attr_name, name))
1359318
function sortAttrsValues(attrs, compareAttributesAsJSON) {
    /**
     * Recursively sorts the given object by key
     * @param {Object} obj
     * @returns {Object}
     */
    function _sortObj(obj) {
        if (!_.isObject(obj)) {
            return JSON.stringify(obj);
        }

        if (_.isArray(obj)) {
            return '[' + _(obj).map(_sortObj).join(',') + ']';
        }

        return '{' +
            _(obj)
                .keys()
                .sort()
                .map(function (key) {
                    return JSON.stringify(key) + ':' + _sortObj(obj[key]);
                })
                .join(',') +
            '}';
    }

    /**
     * Parses the given in HTML attribute JSON
     * @param {String} val
     * @param {Boolean} [isClick]
     * @returns {Object}
     */
    function _parseAttr(val, isClick) {
        try {
            if (isClick) {
                /*jshint evil: true */
                var fn = Function(val);

                return fn ? fn() : {};
            }

            return JSON.parse(val);
        } catch (err) {
            return undefined;
        }
    }

    _.forEach(compareAttributesAsJSON, function (attr) {
        if (typeof attr === 'string') {
            var name = attr;
            attr = {};
            attr.name = name;
            attr.isFunction = false;
        }

        var attrValue,
            isFunction = (attr.isFunction),
            attrIndexes = _getIndexesInArray(attrs, attr.name);

        _.forEach(attrIndexes, function (index) {
            attrValue = _parseAttr(attrs[index].value, isFunction);

            attrValue = _sortObj(attrValue);

            attrs[index].value = (isFunction && attrValue ? 'return ' : '') + attrValue;
        });
    });

    return attrs;
}
1019246
def sort(self, *args, **kwargs):
		""""""
		self._list.sort(*args, **kwargs)
		for index, value in enumerate(self._list):
			self._dict[value] = index