Java Utililty Methods Bubble Sort

List of utility methods to do Bubble Sort

  1. HOME
  2. Java
  3. B
  4. Bubble Sort

Description

The list of methods to do Bubble Sort are organized into topic(s).

Method

int[] bubbleSort(int array[], int index[])
Bubble Sort for Integer array
boolean swappedOnPrevRun = true;
while (swappedOnPrevRun) {
 swappedOnPrevRun = false;
 for (int i = 0; i < array.length - 1; i++)
 if (array[i] > array[i + 1])
 swappedOnPrevRun = true; 
...
void bubbleSort(int[] a)
bubble Sort
for (int i = 0; i < a.length - 1; i++) {
 for (int j = 0; j < a.length - i - 1; j++) {
 if (a[j] > a[j + 1]) {
 int temp = a[j];
 a[j] = a[j + 1];
 a[j + 1] = temp;
void bubbleSort(int[] array)
bubble Sort
int n = array.length;
boolean doMore = true;
while (doMore) {
 n--;
 doMore = false; 
 for (int i = 0; i < n; i++) {
 if (array[i] > array[i + 1]) {
 int temp = array[i];
...
void BubbleSort(int[] data)
Bubble Sort
int[] bubbleSort(int[] source)
bubble Sort
for (int i = 1; i < source.length; i++) {
 for (int j = 0; j < i; j++) {
 if (source[j] > source[j + 1]) {
 swap(source, j, j + 1);
return source;
...
void bubbleSort(String[] p_array)
bubble Sort
boolean anyCellSorted;
int length = p_array.length;
String tmp;
for (int i = length; --i >= 0;) {
 anyCellSorted = false;
 for (int j = 0; j < i; j++) {
 if (p_array[j].compareTo(p_array[j + 1]) > 0) {
 tmp = p_array[j];
...
String[] bubbleSortArray(String[] str)
bubble Sort Array
String temp = null;
for (int i = str.length - 1; i > 0; --i) {
 for (int j = 0; j < i; ++j) {
 if (str[j + 1].length() < str[j].length()) {
 temp = str[j];
 str[j] = str[j + 1];
 str[j + 1] = temp;
return str;
double[][] bubbleSorting(double array[], double[] diagramsUsed)
Taken from http://www.java2novice.com/java-sorting-algorithms/bubble-sort/
int n = array.length;
int k;
for (int m = n; m >= 0; m--) {
 for (int i = 0; i < n - 1; i++) {
 k = i + 1;
 if (array[i] > array[k]) {
 swapNumbers(i, k, array);
 swapNumbers(i, k, diagramsUsed);
...
String[][] bubblesortList(String[][] SortList)
bubblesort List
String DisplayDummy;
int SortCount = SortList[0].length;
int DimCount = SortList.length;
for (int s = 0; s < SortCount; s++) {
 for (int t = 0; t < SortCount - s - 1; t++) {
 if (SortList[0][t].compareTo(SortList[0][t + 1]) > 0) {
 for (int k = 0; k < DimCount; k++) {
 DisplayDummy = SortList[k][t];
...


AltStyle によって変換されたページ (->オリジナル) /