Java Bubble Sort bubblesortList(String[][] SortList)

Here you can find the source of bubblesortList(String[][] SortList)

Description

bubblesort List

License

Open Source License

Declaration

public static String[][] bubblesortList(String[][] SortList) 

Method Source Code

//package com.java2s;
/*************************************************************************
 * /*ww w. j a va2s.  co  m*/
 *  Copyright 2009 by Giuseppe Castagno beppec56@openoffice.org
 *  
 *  The Contents of this file are made available subject to
 *  the terms of European Union Public License (EUPL) version 1.1
 *  as published by the European Community.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the EUPL.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  EUPL for more details.
 *
 *  You should have received a copy of the EUPL along with this
 *  program.  If not, see:
 *  https://www.osor.eu/eupl, http://ec.europa.eu/idabc/eupl.
 *
 ************************************************************************/

public class Main {
    /**
     * @author bc93774 This function bubble sorts an array of with 2 dimensions.
     *         The default sorting order is the first dimension Only if
     *         sort2ndValue is True the second dimension is the relevant for the
     *         sorting order
     */
    public static String[][] bubblesortList(String[][] SortList) {
        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];
                        SortList[k][t] = SortList[k][t + 1];
                        SortList[k][t + 1] = DisplayDummy;
                    }
                }
            }
        }
        return SortList;
    }
}

Related

  1. BubbleSort(int[] data)
  2. bubbleSort(int[] source)
  3. bubbleSort(String[] p_array)
  4. bubbleSortArray(String[] str)
  5. bubbleSorting(double array[], double[] diagramsUsed)