- Time Complexity : O(N^2)
- Loop runs from first element to last element if the number is greater than the next number then swap to the next term and so on…
- Do until there should be no swaps left

public class Main
{
public static void main(String[] args) {
int[] arr = new int[] {12,3,5,9,7};
for(int i=0;i<arr.length;i++) // 12,3,5,9,7
{
int temp=0;
for(int j=i+1;j<arr.length;j++) //3,5,9,7
{
if(arr[i]>arr[j])
{
temp = arr[i]; //swapping storing first element
arr[i] = arr[j];//storing second element to first
arr[j] = temp;//assigning second element to first
}
}
}
for(int i=0;i<arr.length;i++)
{
System.out.println(arr[i]);
}
}
}