Java Bubble Sort bubbleSort(int[] a)

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

Description

bubble Sort

License

Apache License

Declaration

public static void bubbleSort(int[] a) 

Method Source Code

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

public class Main {

    public static void bubbleSort(int[] a) {
        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];//from  ww w.  ja v a2  s  .  c  o m
                    a[j + 1] = temp;
                }
            }
        }
    }
}

Related

  1. bubbleSort(int array[], int index[])
  2. bubbleSort(int[] array)
  3. BubbleSort(int[] data)
  4. bubbleSort(int[] source)
  5. bubbleSort(String[] p_array)