没什么好说的直接组成6位数比较大小即可
import java.math.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.*; public class Main { public static void main(String args[])throws IOException { StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); PriorityQueue<Integer> queue = new PriorityQueue<>(); in.nextToken(); int n = (int)in.nval; int num[] = new int[n]; for(int i=0;i<n;i++) { in.nextToken(); int x = (int)in.nval; in.nextToken(); int y = (int)in.nval; in.nextToken(); int z = (int)in.nval; num[i] = z+y*100+x*10000; } Arrays.sort(num); for(int i=0;i<n;i++) { out.println(num[i]/10000+" "+num[i]/100%100+" "+num[i]%100); } out.flush(); } }