Answers for "sorted() descending"

1

sorting in descending order

ArrayList -- sorting in descending order
Write a method that can sort the ArrayList in descending order
without using the sort method
 
Solution:
public static void SortingArrayListDesc(List<Integer> list) {
        for (int i = 0; i < list.size(); i++) {
        for (int j = 0; j < list.size(); j++) {
        if (list.get(i) > list.get(j)) {
                    Integer temp = list.get(i);
                    list.set(i, list.get(j));
                    list.set(j, temp);
                    }
            }
   }
    }
Posted by: Guest on September-29-2021

Code answers related to "sorted() descending"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language