Sort a small array using repetitive insertion sort.

@param data Data to sort
@param start Interval start
@param end Interval end
557491
private static <T> void insertionSort(T data, Adapter<T> adapter, int start, int end) {
    for(int i = start + 1; i < end; i++) {
      for(int j = i; j > start && adapter.compare(data, j - 1, j) > 0; j--) {
        adapter.swap(data, j, j - 1);
      }
    }
  }
665562
public synchronized boolean addSorted(SpdData data) {
        if (data == null) {
            return false;
        } else if (members.contains(data)) {
            return false;
        } else {
            return (insert(data) != -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;
        }
    }
493018
private static void insertionSortReverse(double[] keys, int[] vals, final int start, final int end) {
    // Classic insertion sort.
    for(int i = start + 1; i < end; i++) {
      for(int j = i; j > start; j--) {
        if(keys[j] <= keys[j - 1]) {
          break;
        }
        swap(keys, vals, j, j - 1);
      }
    }
  }
1368527
public static <E extends Comparable<E>> void sortDescending(E[] intArray) {
        Merge.sort(intArray, 0, intArray.length-1, true);
    }
921004
public static void sortDescending(long[] longArray) {
        int index = 0;
        long value = 0;
        
        for(int i = 1; i < longArray.length; i++) {
            index = i;
            value = longArray[index];
            
            while(index > 0 && value > longArray[index - 1]) {
                longArray[index] = longArray[index - 1];
                
                index--;
            }
            
            longArray[index] = value;
        }
    }
977071
public static INDArrayIndex[] createFromStartAndEnd(INDArray start, INDArray end) {
        if (start.length() != end.length())
            throw new IllegalArgumentException("Start length must be equal to end length");
        else {
            if (start.length() > Integer.MAX_VALUE)
                throw new ND4JIllegalStateException("Can't proceed with INDArray with length > Integer.MAX_VALUE");

            INDArrayIndex[] indexes = new INDArrayIndex[(int) start.length()];
            for (int i = 0; i < indexes.length; i++) {
                indexes[i] = NDArrayIndex.interval(start.getInt(i), end.getInt(i));
            }
            return indexes;
        }
    }
606109
private void sort(final T[] array, int start, int end, Comparator<T> lt) {
    if (start == end)
      return;
    if ((end - start) <= 15)
      this.selectionSort(array, start, end, lt);
    else {
      final T pivot = array[start + ((end - start) / 2)];
      T tmp;
      int i = start - 1;
      int j = end;
      while (true) {
        do
          i++;
        while (lt.compare(array[i], pivot) < 0);
        do
          j--;
        while (lt.compare(pivot, array[j]) < 0);
        if (i >= j)
          break;
        tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
      }
      this.sort(array, start, i, lt);
      this.sort(array, i, end, lt);
    }
  }
404043
public Matcher matcher(char[] data, int start, int end) {
        Matcher m = new Matcher(this);
        m.setTarget(data, start, end);
        return m;
    }
61261
public void sort() {
        if (initial)
            Arrays.sort(data, 0, size, comparator);
        else if (size > limit)
            sortTail();
    }
1098903
private static void insertionSort(final int off, final int len, int[] order, IndirectComparator intComparator) {
    for (int i = off + 1; i < off + len; i++) {
      final int v = order[i];
      int j = i, t;
      while (j > off && intComparator.compare(t = order[j - 1], v) > 0) {
        order[j--] = t;
      }
      order[j] = v;
    }
  }
1245317
private static void quickSort(int[] data, final int start, final int end, Comparator<? super DBIDRef> comp, IntegerDBIDVar vl, IntegerDBIDVar vk, IntegerDBIDVar vr) {
    final int len = end - start;
    if(len < INSERTION_THRESHOLD) {
      // Classic insertion sort.
      for(int i = start + 1; i <= end; i++) {
        for(int j = i; j > start; j--) {
          vl.internalSetIndex(data[j]);
          vr.internalSetIndex(data[j - 1]);
          if(comp.compare(vl, vr) < 0) {
            int tmp = data[j - 1];
            data[j - 1] = data[j];
            data[j] = tmp;
          }
          else {
            break;
          }
        }
      }
      return;
    }

    // Choose pivots by looking at five candidates.
    final int seventh = (len >> 3) + (len >> 6) + 1;
    final int m3 = (start + end) >> 1; // middle
    final int m2 = m3 - seventh;
    final int m1 = m2 - seventh;
    final int m4 = m3 + seventh;
    final int m5 = m4 + seventh;

    // Explicit (and optimal) sorting network for 5 elements
    // See Knuth for details.
    if(compare(vl, data[m1], vk, data[m2], comp) > 0) {
      int tmp = data[m2];
      data[m2] = data[m1];
      data[m1] = tmp;
    }
    if(compare(vl, data[m1], vk, data[m3], comp) > 0) {
      int tmp = data[m3];
      data[m3] = data[m1];
      data[m1] = tmp;
    }
    if(compare(vl, data[m2], vk, data[m3], comp) > 0) {
      int tmp = data[m3];
      data[m3] = data[m2];
      data[m2] = tmp;
    }
    if(compare(vl, data[m4], vk, data[m5], comp) > 0) {
      int tmp = data[m5];
      data[m5] = data[m4];
      data[m4] = tmp;
    }
    if(compare(vl, data[m1], vk, data[m4], comp) > 0) {
      int tmp = data[m4];
      data[m4] = data[m1];
      data[m1] = tmp;
    }
    if(compare(vl, data[m3], vk, data[m4], comp) > 0) {
      int tmp = data[m4];
      data[m4] = data[m3];
      data[m3] = tmp;
    }
    if(compare(vl, data[m2], vk, data[m5], comp) > 0) {
      int tmp = data[m5];
      data[m5] = data[m2];
      data[m2] = tmp;
    }
    if(compare(vl, data[m2], vk, data[m3], comp) > 0) {
      int tmp = data[m3];
      data[m3] = data[m2];
      data[m2] = tmp;
    }
    if(compare(vl, data[m4], vk, data[m5], comp) > 0) {
      int tmp = data[m5];
      data[m5] = data[m4];
      data[m4] = tmp;
    }

    // Choose the 2 and 4th as pivots, as we want to get three parts
    // Copy to variables v1 and v3, replace them with the start and end
    // Note: do not modify v1 or v3 until we put them back!
    vl.internalSetIndex(data[m2]);
    vr.internalSetIndex(data[m4]);
    data[m2] = data[start];
    data[m4] = data[end];

    // A tie is when the two chosen pivots are the same
    final boolean tied = comp.compare(vl, vr) == 0;

    // Insertion points for pivot areas.
    int left = start + 1;
    int right = end - 1;

    // Note: we merged the ties and no ties cases.
    // This likely is marginally slower, but not at a macro level
    // And you never know with hotspot.
    for(int k = left; k <= right; k++) {
      int tmp = data[k];
      vk.internalSetIndex(tmp);
      final int c = comp.compare(vk, vl);
      if(c == 0) {
        continue;
      }
      else if(c < 0) {
        // Traditional quicksort
        data[k] = data[left];
        data[left] = tmp;
        left++;
      }
      else if(tied || comp.compare(vk, vr) > 0) {
        // Now look at the right. First skip correct entries there, too
        while(true) {
          vk.internalSetIndex(data[right]);
          if(comp.compare(vk, vr) > 0 && k < right) {
            right--;
          }
          else {
            break;
          }
        }
        // Now move tmp from k to the right.
        data[k] = data[right];
        data[right] = tmp;
        right--;
        // Test the element we just inserted: left or center?
        vk.internalSetIndex(data[k]);
        if(comp.compare(vk, vl) < 0) {
          tmp = data[k];
          data[k] = data[left];
          data[left] = tmp;
          left++;
        } // else: center. cannot be on right.
      }
    }
    // Put the pivot elements back in.
    // Remember: we must not modify v1 and v3 above.
    data[start] = data[left - 1];
    data[left - 1] = vl.internalGetIndex();
    data[end] = data[right + 1];
    data[right + 1] = vr.internalGetIndex();
    // v1 and v3 are now safe to modify again. Perform recursion:
    quickSort(data, start, left - 2, comp, vl, vk, vr);
    // Handle the middle part - if necessary:
    if(!tied) {
      // TODO: the original publication had a special tie handling here.
      // It shouldn't affect correctness, but probably improves situations
      // with a lot of tied elements.
      quickSort(data, left, right, comp, vl, vk, vr);
    }
    quickSort(data, right + 2, end, comp, vl, vk, vr);
  }
37283
public void sort() {
        if (!sorted) {
            sort(heap, Math.min(k,n));
            sorted = true;
        }
    }
139143
private void sortData() {
        sortedList.clear();
        for (DataPoint dataPoint : DATA_LIST) {
            sortedList.add(dataPoint.getValue());
        }
        Collections.sort(sortedList);
    }
879999
public static void sort(float[] floatArray) {
        int index = 0;
        float value = 0f;
        
        for(int i = 1; i < floatArray.length; i++) {
            index = i;
            value = floatArray[index];
            
            while(index > 0 && value < floatArray[index - 1]) {
                floatArray[index] = floatArray[index - 1];
                
                index--;
            }
            
            floatArray[index] = value;
        }
    }
976397
public void append (CharSequence text, int start, int end){
		mInputView.append(text, start, end);
	}
554138
public static void sort(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;
        }
    }