Replace the Comparator at the given index using the given sort order.

@param index the index of the Comparator to replace
@param comparator the Comparator to place at the given index
@param ascending the sort order: ascending (true) or descending (false)
163399
public void setComparator(int index, Comparator<T> comparator, boolean ascending) {
        this.comparators.set(index, new InvertibleComparator<>(comparator, ascending));
    }
103277
public static void sortDescending(byte[] byteArray) {
        int index = 0;
        byte value = 0;
        
        for(int i = 1; i < byteArray.length; i++) {
            index = i;
            value = byteArray[index];
            
            while(index > 0 && value > byteArray[index - 1]) {
                byteArray[index] = byteArray[index - 1];
                
                index--;
            }
            
            byteArray[index] = value;
        }
    }
391083
public static void sortDescending(int[] intArray) {
        boolean swapped = true;
        
        while(swapped) {
            swapped = false;
            
            for(int i = 0; i < (intArray.length - 1 ); i++) {
                if(intArray[i] < intArray[i + 1]) {
                    TrivialSwap.swap(intArray, i, i + 1);
                    
                    swapped = true;
                }
            }            
        }
    }
818177
public void setSort(String property, Boolean order) {
    	SortOrder sortOrder = order==null?SortOrder.ASCENDING:(order?SortOrder.ASCENDING:SortOrder.DESCENDING);
    	if(property==null) {
    		if(order==null) setSort(null);
    		else setSort("@rid", sortOrder);
    	} else {
    		super.setSort(property, sortOrder);
    	}
    }
845890
public void remove( int index )
	{
		if( (index < 0) || (index >= size) )
		{
			throw new IndexOutOfBoundsException();
		}

		--size;
		for( int i = index; i < size; ++i )
		{
			array[i] = array[i + 1];
		}

		array[size] = null;
	}
1003719
public void setSorting(List<SortProperty> newSorting) {
		Validate.notNull(newSorting, "Sorting required");

		if (!sorting.equals(newSorting)) {
			sorting.clear();
			sorting.addAll(newSorting);
			selectionIndex = -1;
			clearCache();
		}
	}
432983
public ComparatorChain<E> setComparator(final int index, final Comparator<E> comparator) throws IndexOutOfBoundsException {
		return setComparator(index, comparator, false);
	}
1371674
protected void fixupWithComparator(int k) {
        if (onMinLevel(k)) {
            int p = k / 2;
            K kValue = array[k];
            if (p > 0 && comparator.compare(array[p], kValue) < 0) {
                array[k] = array[p];
                array[p] = kValue;
                fixupMaxWithComparator(p);
            } else {
                fixupMinWithComparator(k);
            }
        } else {
            int p = k / 2;
            K kValue = array[k];
            if (p > 0 && comparator.compare(kValue, array[p]) < 0) {
                array[k] = array[p];
                array[p] = kValue;
                fixupMinWithComparator(p);
            } else {
                fixupMaxWithComparator(k);
            }
        }
    }
503245
@Override
    public T remove(int index) {
        if (displacement != null) {
            return super.get(index - displacement);
        }
        return super.remove(index);
    }
538310
public static void sortDescending(double[] doubleArray) {
        int index = 0;
        double value = 0;
        
        for(int i = 1; i < doubleArray.length; i++) {
            index = i;
            value = doubleArray[index];
            
            while(index > 0 && value > doubleArray[index - 1]) {
                doubleArray[index] = doubleArray[index - 1];
                
                index--;
            }
            
            doubleArray[index] = value;
        }
    }
1042591
public static <T> Sequence<T> sort(final Sequence<T> sequence, final Comparator<T> comparator)
  {
    List<T> seqList = Sequences.toList(sequence, Lists.<T>newArrayList());
    Collections.sort(seqList, comparator);
    return BaseSequence.simple(seqList);
  }
1179422
public OQueryModel<K> setSort(String sortableParameter, SortOrder order)
    {
    	setSortableParameter(sortableParameter);
    	setAscending(SortOrder.ASCENDING.equals(order));
    	return this;
    }
145222
public static <E extends Comparable<E>> void sortDescending(List<E> list) {
        Quicksort.sort(list, 0, list.size() - 1, true);
    }
292903
public void reorderValue(final InputColumn<?>[] sortedValue) {
        // the offset represents the search textfield and the button panel
        final int offset = 2;

        // reorder the visual components
        for (int i = 0; i < sortedValue.length; i++) {
            final InputColumn<?> inputColumn = sortedValue[i];
            final JComponent decoration = getOrCreateCheckBoxDecoration(inputColumn, true);
            final int position = offset + i;
            add(decoration, position);
        }
        updateUI();

        // recreate the _checkBoxes map
        final TreeMap<InputColumn<?>, DCCheckBox<InputColumn<?>>> checkBoxesCopy = new TreeMap<>(_checkBoxes);
        _checkBoxes.clear();
        for (final InputColumn<?> inputColumn : sortedValue) {
            final DCCheckBox<InputColumn<?>> checkBox = checkBoxesCopy.get(inputColumn);
            _checkBoxes.put(inputColumn, checkBox);
        }
        _checkBoxes.putAll(checkBoxesCopy);
        setValue(sortedValue);
    }
159938
@Override
    public void sortAtomContainers(final Comparator<IAtomContainer> comparator) {

        // need to use boxed primitives as we can't customise sorting of int primitives
        Integer[] indexes = new Integer[atomContainerCount];
        for (int i = 0; i < indexes.length; i++)
            indexes[i] = i;

        // proxy the index comparison to the atom container comparator
        Arrays.sort(indexes, new Comparator<Integer>() {

            @Override
            public int compare(Integer o1, Integer o2) {
                return comparator.compare(atomContainers[o1], atomContainers[o2]);
            }
        });

        // copy the original arrays (we could modify in place with swaps but this is cleaner)
        IAtomContainer[] containersTmp = Arrays.copyOf(atomContainers, indexes.length);
        Double[] multipliersTmp = Arrays.copyOf(multipliers, indexes.length);

        // order the arrays based on the order of the indices
        for (int i = 0; i < indexes.length; i++) {
            atomContainers[i] = containersTmp[indexes[i]];
            multipliers[i] = multipliersTmp[indexes[i]];
        }

    }
10872
public <T> void sort(List<T> list, Comparator<T> cmp)
    {
        if(index.size() < list.size())
            for(int i = index.size(); i < list.size(); i++ )
                index.add(i);
        if(list.size() == index.size())
            Collections.sort(index, new IndexViewCompList(list, cmp));
        else
        {
            Collections.sort(index);//so [0, list.size) is at the front
            Collections.sort(index.subList(0, list.size()), new IndexViewCompList(list, cmp));
        }
        prevSize = list.size();
    }
289066
public void sortChildrenByNode(Comparator<TreeNode<T>> comparator) {
		Collections.sort(children, comparator);
		for (TreeNode<T> child : children) {
			child.sortChildrenByNode(comparator);
		}
	}