Answers for "sorting reverse order"


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
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 "Java"

Java Answers by Framework

Browse Popular Code Answers by Language