Here you can find the source of bubbleSorting(double array[], double[] diagramsUsed)
Taken from http://www.java2novice.com/java-sorting-algorithms/bubble-sort/
Parameter | Description |
---|---|
array | that will be sorted |
diagramsUsed | the number associated to the diagram |
public static double[][] bubbleSorting(double array[], double[] diagramsUsed)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w . j ava2 s . c o m * Taken from * http://www.java2novice.com/java-sorting-algorithms/bubble-sort/ * * @param array * that will be sorted * @param diagramsUsed * the number associated to the diagram * @return sorted array and diagrams used by minimizing array */ public static double[][] bubbleSorting(double array[], double[] diagramsUsed) { 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); } } } double[][] arrayAndPositions = { array, diagramsUsed }; return arrayAndPositions; } /** * * @param i * row index * @param j * col index * @param array * modified vector */ private static void swapNumbers(int i, int j, double[] array) { double temp; temp = array[i]; array[i] = array[j]; array[j] = temp; } }