请问为什么第三个for循环没有实现排序,或者说有更好的排序代码吗
import java.util.Arrays; public class HelloWorld { public static void main(String[] args) { HelloWorld hello = new HelloWorld(); int[] rank = {89, -23, 64, 91, 119, 52, 73}; hello.getArrays(rank); }//定义方法完成成绩排序并输出前三名的功能 public int[] getArrays(int []rank) { int max3=rank[0]; int max2=rank[0]; int max1=rank[0]; int[] nums = {1, 2, 3}; for (int i = 0; i < rank.length-1; i++) { if (rank[i] > 1 && rank[i] < 100) { if (rank[0] < rank[i]) { max1 = rank[i]; } } } for (int i = 0; i < rank.length-1; i++) { if (rank[0] <rank[i]&&rank[i]<max1) { if (rank[i] > 1 && rank[i] < 100) { max2 =rank[i]; } } } for(int i=1;i<rank.length;i++){ if(rank[i]>rank[i]){ max3=rank[i]; } } nums[0]=max1;nums[1]=max2;nums[2]=max3; System.out.println(Arrays.toString(nums)); return nums; } }
输出是91 89 89?