We assume AsciiMath is being used in the terms & definitions.
 Indices sort after letter but before any following
 letter (x, x_m, x_1, xa); we use colon to force that sort order.
 Numbers sort *after* letters; we use thorn to force that sort order.
325489
def symbol_key(x)
      HTMLEntities.new.decode(x.text).gsub(/_/, ":").gsub(/`/, "").
        gsub(/[0-9]+/, "þ\\1")
    end
994559
function sortedIndex(element) {
    /* jshint validthis:true */
    var index = binarySearch(toArray(this), element, this.comparator);

    if (index < 0) {
        // binarySearch decreases the negative index by one because otherwise the index 0 would stand for two results
        // @see https://github.com/darkskyapp/binary-search/issues/1
        return Math.abs(index) - 1;
    } else {
        return index;
    }
}
620356
function comparator(a, b) {
    var aHasIndex = a.hasOwnProperty('index'),
        bHasIndex = b.hasOwnProperty('index');

    if (aHasIndex) {
      if (bHasIndex) {
        if (a.index != b.index) {
          return a.index - b.index;
        }
      }
      else {
        return -1;
      }
    }

    else if (bHasIndex) {
      return 1;
    }

    var aHasTimestamp = a.hasOwnProperty('timestamp'),
        bHasTimestamp = b.hasOwnProperty('timestamp');

    if (aHasTimestamp) {
      if (bHasTimestamp) {
        if (a.timestamp != b.timestamp) {
          return b.timestamp - a.timestamp;
        }
      }
      else {
        return -1;
      }
    }

    else if (bHasTimestamp) {
      return 1;
    }
    
    return a.name > b.name ? 1 : -1;
  }
1130712
public static void sortDescending(short[] shortArray) {
        int index = 0;
        short value = 0;
        
        for(int i = 1; i < shortArray.length; i++) {
            index = i;
            value = shortArray[index];
            
            while(index > 0 && value > shortArray[index - 1]) {
                shortArray[index] = shortArray[index - 1];
                
                index--;
            }
            
            shortArray[index] = value;
        }
    }
1326865
function _sort(a,b) {
    if (a.weight < b.weight) {
      return 1;
    }
    else if (a.weight > b.weight) {
      return -1;
    }
    else {
      return 0;
    }
  }
339330
public void sortSubTerms() {
        final int subTermNum = subTerms.size();

        if (subTerms != null && subTermNum > 0) {
            Collections.sort(subTerms);
            for (final IndexTerm subTerm : subTerms) {
                subTerm.sortSubTerms();
            }
        }
    }
505336
protected function _sort()
        {
            if ($this->_dirtyIndex) {
                $newIndex = array();
                $index = 0;

                foreach ($this->_pages as $hash => $page) {
                    $order = $page->getOrder();
                    if ($order === null) {
                        $newIndex[$hash] = $index;
                        $index++;
                    } else {
                        $newIndex[$hash] = $order;
                    }
                }

                asort($newIndex);

                $this->_index = $newIndex;
                $this->_dirtyIndex = false;
            }
        }
123484
public static void sort(int n, int[] Xip, int Xip_offset, int[] Xlen, int Xlen_offset,
			double[] LU, int[] Tp, int[] Tj, double[] Tx, int[] W)
	{
		/*int[]*/double[] Xi ;
		double[] Xx ;
		int p, i, j, nz, tp, xlen, pend ;
		int[] len = new int[1] ;
		int[] Xi_offset = new int[1] ;
		int[] Xx_offset = new int[1] ;

		ASSERT (klu_valid_LU (n, FALSE, Xip, Xip_offset, Xlen, Xlen_offset, LU)) ;

		/* count the number of entries in each row of L or U */
		for (i = 0 ; i < n ; i++)
		{
			W [i] = 0 ;
		}
		for (j = 0 ; j < n ; j++)
		{
			Xi = Xx = GET_POINTER (LU, Xip, Xip_offset, Xlen, Xlen_offset, Xi_offset, Xx_offset, j, len) ;
			for (p = 0 ; p < len[0] ; p++)
			{
				W [(int) Xi [Xi_offset[0] + p]]++ ;
			}
		}

		/* construct the row pointers for T */
		nz = 0 ;
		for (i = 0 ; i < n ; i++)
		{
			Tp [i] = nz ;
			nz += W [i] ;
		}
		Tp [n] = nz ;
		for (i = 0 ; i < n ; i++)
		{
			W [i] = Tp [i] ;
		}

		/* transpose the matrix into Tp, Ti, Tx */
		for (j = 0 ; j < n ; j++)
		{
			Xi = Xx = GET_POINTER (LU, Xip, Xip_offset, Xlen, Xlen_offset, Xi_offset, Xx_offset, j, len) ;
			for (p = 0 ; p < len[0] ; p++)
			{
				tp = W [(int) Xi [Xi_offset[0] + p]]++ ;
				Tj [tp] = j ;
				Tx [tp] = Xx [Xx_offset[0] + p] ;
			}
		}

		/* transpose the matrix back into Xip, Xlen, Xi, Xx */
		for (j = 0 ; j < n ; j++)
		{
			W [j] = 0 ;
		}
		for (i = 0 ; i < n ; i++)
		{
			pend = Tp [i+1] ;
			for (p = Tp [i] ; p < pend ; p++)
			{
				j = Tj [p] ;
				Xi = Xx = GET_POINTER (LU, Xip, Xip_offset, Xlen, Xlen_offset, Xi_offset, Xx_offset, j, len) ;
				xlen = W [j]++ ;
				Xi [Xi_offset[0] + xlen] = i ;
				Xx [Xx_offset[0] + xlen] = Tx [p] ;
			}
		}

		ASSERT (klu_valid_LU (n, FALSE, Xip, Xip_offset, Xlen, Xlen_offset, LU)) ;
	}
1157515
protected void sortIndexMap() {
        for (List<Doc> docs : indexmap.values()) {
            Collections.sort(docs, configuration.utils.makeComparatorForIndexUse());
        }
    }
605618
def sortable
      [
        last,
        [
          prefix,
          first,
          middle,
          suffix
        ].reject( &:blank? ).
          join( ' ' )
      ].reject( &:blank? ).
        join( ', ' )
    end
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
212699
def sort_idx(m, reverse=False):
    """"""
    return sorted(range(len(m)), key=lambda k: m[k], reverse=reverse)
995711
public boolean canMergeRemainderOrdering(OrderingScore<S> other) {
        if (this == other || (getHandledCount() == 0 && other.getHandledCount() == 0)) {
            return true;
        }

        if (isIndexClustered() == other.isIndexClustered()
            && getIndexPropertyCount() == other.getIndexPropertyCount()
            && shouldReverseOrder() == other.shouldReverseOrder()
            && getHandledOrdering().equals(other.getHandledOrdering()))
        {
            // The remainder orderings cannot conflict.
            OrderingList<S> thisRemainderOrdering = getRemainderOrdering();
            OrderingList<S> otherRemainderOrdering = other.getRemainderOrdering();

            int size = Math.min(thisRemainderOrdering.size(), otherRemainderOrdering.size());
            for (int i=0; i<size; i++) {
                if (!thisRemainderOrdering.get(i).equals(otherRemainderOrdering.get(i))) {
                    return false;
                }
            }

            return true;
        }

        return false;
    }
487312
public static void sort(char[] charArray) {
        int index = 0;
        char value = 0;
        
        for(int i = 1; i < charArray.length; i++) {
            index = i;
            value = charArray[index];
            
            while(index > 0 && value < charArray[index - 1]) {
                charArray[index] = charArray[index - 1];
                
                index--;
            }
            
            charArray[index] = value;
        }
    }
162010
def sort_key(x):
    
    name, (r, u) = x
    return - len(u) + u.count('}') * 100
224080
function sortArrayByIndex(array) {

  let ii = 0;
  let length = array.length;

  let output = [];

  for (; ii < length; ++ii) {
    output[array[ii].index] = array[ii];
    delete array[ii].index;
  };

  return (output);

}
1333573
def sort_order(options = {})
      [[prefix, last].compact.join(' '), suffix, options[:initials] ? initials : first].compact.join(', ')
    end