集册 Java实例教程 对两个数组排序

对两个数组排序

欢马劈雪     最近更新时间:2020-01-02 10:19:05

480
对两个数组排序


import java.util.ArrayList;

import java.util.Collections;// from nowjava - 时  代  Java

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);

    }

    public synchronized static void sortTwoArrays(Double[] queryList,

            Double[] secondList) {

        if (queryList.length != secondList.length) {

            throw new IllegalArgumentException(// from 时 代 J a v a 公 众 号 - nowjava.com

                    "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();

      
展开阅读全文