Java examples for Collection Framework:Array Sort
sort Two Arrays
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Map.Entry; public class Main{ public static void main(String[] argv){ double[] queryList = new int[]{34.45,35.45,36.67,37.78,37.0000,37.1234,67.2344,68.34534,69.87700}; double[] secondList = new int[]{34.45,35.45,36.67,37.78,37.0000,37.1234,67.2344,68.34534,69.87700}; sortTwoArrays(queryList,secondList); }//from w w w. j a v a 2 s .c o m public synchronized static void sortTwoArrays(Double[] queryList, Double[] secondList) { if (queryList.length != secondList.length) { throw new IllegalArgumentException( "The lists have to be of equal size!"); } int n = queryList.length; for (int i = 0; i < n; i++) { for (int j = n - 1; j > i; j--) { double one = queryList[j - 1].doubleValue(); double two = queryList[j].doubleValue(); if (one > two) { queryList[j - 1] = two; queryList[j] = one; Double temp = secondList[j - 1]; secondList[j - 1] = secondList[j]; secondList[j] = temp; } } } } }