Collections

How to Int sort arraylist in java without using sort method

package com.candidjava;

import java.util.ArrayList;

public class Intarraysortingwithoutsort {
  public static void main(String[] args) {
    ArrayList<Integer> al = new ArrayList<Integer>();
    al.add(10);
    al.add(60);
    al.add(20);
    al.add(70);
    al.add(100);
    System.out.println("unsorted arraylist:");
    System.out.println(al);
    for (int i = 0; i < al.size(); i++) {
      for (int j = i + 1; j < al.size(); j++) {

        if (al.get(i) > al.get(j)) {
          int tmp = al.get(i);
          al.set(i, al.get(j));
          al.set(j, tmp);
        }

      }

    }
    System.out.println("Sorted Arraylist:");
    for (int i : al) {

      System.out.println(i);

    }
  }
}

OUTPUT

unsorted arraylist:
[10, 60, 20, 70, 100]
Sorted Arraylist:
10
20
60
70
100