+ 1
Can you check the Java code and tell me why this Array is not sorting by using Array.sort(); [Solved]
5 odpowiedzi
+ 5
Rabeeh
You are sorting array on index based so your array elements will sort on the basis of that range so here you have sort array from index 1 to 3 so here only 23 and 53 will sort which is already sorted. Here index 1 element is included and index 3 element is excluded
Try to change index 3 to 4 then see effect.
https://code.sololearn.com/cJM6SxWFy45i/?ref=app
+ 3
Your code works fine and what you want to do with your code . .?
Do you want to sort sub array of elements. .?
If yes, your procedure is right ✅.
This is the method of sorting sub array of elements which is in java.util.Arrays;
public static void sort(int[] arr, int from_Index, int to_Index)
first argument took the array ,
second and third arguments tooks integer numbers those represents starting index(inclusive) and ending index(exclusive) of sub array .
Note : it is useful for unsorted sub array .
but in your array elements the sub array from index 1 to 3 (exclusive) means only two elements 23 and 53 already sorted . so no need to sorted it again .
Hope you get ...
H A P P Y C O D I N G 😊
+ 3
🌟αnurαg kumαr🌟
That's not valid answer. You need to check first why there is 1, 3 in sort method.