1public class SortingData {
2 public static void main(String[] args)
3 {
4 int[] arr = { 13, 7, 6, 45, 21, 9, 101, 102 };
5
6 Arrays.sort(arr);//sort() function
7
8 System.out.printf("Modified arr[] : %s",
9 Arrays.toString(arr));
10 }
11}
1for (int i = 0; i < arr.length; i++) {
2 for (int j = 0; j < arr.length-1-i; j++) {
3 if(arr[j]>arr[j+1])
4 {
5 int temp=arr[j];
6 arr[j]=arr[j+1];
7 arr[j+1]=temp;
8 }
9 }
10 System.out.print("Iteration "+(i+1)+": ");
11 printArray(arr);
12 }
13 return arr;
14// BUBBLE SORT