1.简述：

81 2 4 9 3 55 64 250

1 2 3 4 9 25 55 64

51 2 3 4 51

5 4 3 2 1

2.代码实现：

import java.util.*;public class Main {    public Main() {    }    public void sortIntegerArray(Integer[] pIntegerArray, int iSortFlag) {        // 按升序        if (iSortFlag == 0) {            Arrays.sort(pIntegerArray, new Comparator<Integer>() {                public int compare(Integer o1, Integer o2) {                    return o1 - o2;                }            });        }        // 按降序        else {            Arrays.sort(pIntegerArray, new Comparator<Integer>() {                public int compare(Integer o1, Integer o2) {                    return o2 - o1;                }            });        }    }    public void output(Integer[] array) {        for (Integer i : array) {            System.out.print(i + " ");        }        System.out.println();    }    public static void main(String[] args) {        Main solution = new Main();        Scanner in = new Scanner(System.in);        while (in.hasNextInt()) {            int n = in.nextInt();            Integer[] array = new Integer[n];            for (int i = 0; i < n; i++) {                array[i] = in.nextInt();            }            int flag = in.nextInt();            solution.sortIntegerArray(array, flag);            solution.output(array);        }    } }