In this video, we will learn How to SORT an Array using Loops.
0:00 Introduction
0:26 Steps
0:45 Understanding all steps with Excel
28:28 Understanding all steps with Code
Here is the program:
public class Sort {
public static void main(String[] args) {
//step - 1 - initializing array
int[] arr = {5, 9, 8, 7, 6, 1, 2, 10, 100, 0};
// step 2 - Defining Loops
// outer loop
for (int i = 0; i LT arr.length; i++) {
// inner loop
for (int j = i+1; j LT arr.length; j++) {
// step - 3 - Comparing Elements
if(arr[i] GT arr[j]){
// step 4 - Swapping if required
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
} // step - 5 - Print element
System.out.print(arr[i]+" ");
}
}
}
On this page of the site you can watch the video online Java Basics - Session - 10 - How to SORT an Array using Loops (Bubble Sort) with a duration of hours minute second in good quality, which was uploaded by the user Khan's Tech Lab 13 July 2025, share the link with friends and acquaintances, this video has already been watched 52 times on youtube and it was liked by 2 viewers. Enjoy your viewing!