Java Bubble Sort bubbleSort(String[] p_array)

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

Description

bubble Sort

License

Open Source License

Declaration

public static void bubbleSort(String[] p_array) throws Exception 

Method Source Code

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

public class Main {
    public static void bubbleSort(String[] p_array) throws Exception {
        boolean anyCellSorted;
        int length = p_array.length;
        String tmp;//from   www  .  j a va  2s.  co  m
        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];
                    p_array[j] = p_array[j + 1];
                    p_array[j + 1] = tmp;
                    anyCellSorted = true;
                }

            }
            if (anyCellSorted == false) {
                return;
            }
        }
    }
}

Related

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