How to sort integer array in Java ? - Ascending/Descending order ? Java tutorial for beginners !

preview_player
Показать описание
How to sort integer array in Java ? - Ascending/Descending order ? Java tutorial for beginners !

In this video we discuss about the following :
Java programming
java basics
How to run java program?
How to sort numbers in Java ?
Sort numbers in java
Sort in ascending order in java
Sort in descending order in java
Sorting in java
Number sorting in java
Sorting using swapping in java
Sorting array in java
How to sort arrays in java

If you find the content informative consider subscribing to our channel and we try our best to post daily videos.
Also if you have any questions don't hesitate to post it in our comment section , we will do our best in replying or to clarify it by making a video with demo.
Your subscription is our motivation.
Рекомендации по теме
Комментарии
Автор

The code you provided is almost correct !
public static void sortArray(int[] array) {
int temp;
for (int i = 0; i < array.length - 1; i++) {
for (int j = i + 1; j < array.length; j++) {
if (array[i] > array[j]) {
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
}

Barak_Mozes
Автор

Guys if you want to do it without so much trouble you can either use Arrays.sort()-->it arrange the array in ascending order
Ex:
int[] arr ={22, 11, 33, 1};
Arrays.sort(arr);

Output-->[1, 11, 22, 33]
Or else you can just write the code given in the video it will help you as u might have to arrange the array in the descending order.

gamingwithjeevu
Автор

Looked so long for how to sort in descending order, you saved me, thanks sir!!

Hompuu
Автор

Bro ur video very useful, pls upload video for
Ques is:merge two arrays and sort the array in ascending and remove the duplicate elements from the array in one program
A[ ]={2, 3, 1, 4, 5, 6, 7};B[ ]={7, 10, 8, 6, 8, 6, 9}

PS-onnh
Автор

thank you. what is the name of this algorithm

elroysamu
Автор

can you explain the backend logic for this program?

karthickhkmy
Автор

great explanation, but why didn't you start j at i+1? considering you are not comparing the first element with itself.

charityg
Автор

this video is so help ful thank you pro

cabdallacali
Автор

Hi... Can you please explain what you used in for loop to print the sorted array..

FoodieSanjana
Автор

What id love to know is why do people refer to using the merge sort algorithm when something like this is so much simpler and less coding overall. What’s so special about merge sort???

Xpert
Автор

Great video! but may I ask if what was the point of this code
temp=num[i];
num[i]=num[j];
num[j]=temp;

loisarcangeles
Автор

Nice job, the best and the simplest code.

pedromoreira
Автор

Exactly my idea at first to do this but failed then looked it up

hey-uoru
Автор

Sir app jis pr coding kr rha ho bo bali link chiya mujhe

kulbhushankumar
Автор

take and array from the user and sort it in assending order and then calculate its median and mode
any one solve this rapidly

MuhammadTalha-uiqd
Автор

I was tasked to fill an array with random numbers and then check if its in increasing order or not how do i simply check for an order? Thanks

spartiva
Автор

bro can we use Arrays class methods for solving such questions in interview? As Arrays class has direct sort method. And can we use collections for solving interview questions?

utkarshgupta
Автор

Can we give this example in bubble sort??

abhisheksingh
Автор

Sir ap program konse software m krte h

ritikaluthra
Автор

shouldn't be i+1? otherwise, you are saying 44 > 44?

rezaarian
visit shbcf.ru