int[] array (sort lowest to highest)

后端 未结 11 1541
悲哀的现实
悲哀的现实 2020-12-01 13:32

So I am not sure why this is becoming so hard for me, but I need to sort high to low and low to high.

For high to low I have:

int a, b;
int temp;
int         


        
11条回答
  •  庸人自扰
    2020-12-01 14:10

    In java8 you can do something like this:

    temp.stream()
        .sorted((e1, e2) -> Integer.compare(e2, e1))
        .forEach(e -> System.out.println(e));  
    

提交回复
热议问题