Java program to sort Arraylist without using collections

  Java program to sort ArrayList without using collections

In this post we will see java program to sort ArrayList without using Collections.sort() method. We will use bubble sort algorithm to sort an ArrayList of integers.

Java program to sort ArrayList in ascending order using bubble sort

Below is the output of above program.

Java program to sort ArrayList in descending order using bubble sort

For descending order we just need to change the logic a.get(j) > a.get(j + 1) to a.get(j) < a.get(j + 1) in the above program. Here is the code.

Below is the output of above program.

Hope you you learned how to sort an ArrayList of integers without using in-built API like Collections.sort() method..

Also Read,

Java program to sort an array of integers using bubble sort

If you have any comments, post it in the comments section.

The following two tabs change content below.
Working as a Java developer since 2010. Passionate about programming in Java. I am a part time blogger.
One comment

Add Comment

Required fields are marked *. Your email address will not be published.