Java Bubble Sort bubbleSort(int[] source)

Here you can find the source of bubbleSort(int[] source)

Description

bubble Sort

License

LGPL

Declaration

public static int[] bubbleSort(int[] source) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {

    public static int[] bubbleSort(int[] source) {
        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);
                }//from   w  ww. j  av  a 2 s . com
            }
        }
        return source;
    }

    public static int[] swap(int[] ints, int x, int y) {
        int temp = ints[x];
        ints[x] = ints[y];
        ints[y] = temp;
        return ints;
    }
}

Related

  1. bubbleSort(int array[], int index[])
  2. bubbleSort(int[] a)
  3. bubbleSort(int[] array)
  4. BubbleSort(int[] data)
  5. bubbleSort(String[] p_array)
  6. bubbleSortArray(String[] str)
  7. bubbleSorting(double array[], double[] diagramsUsed)
  8. bubblesortList(String[][] SortList)