Why Getting Wrong answer

Please tell why am I getting wrong answer. I am sorting all the numbers by the largeness of the first digit, and next digit if previous is equal.

@rishabhsetiya7
You have overcooked your code which is very hard to debug.
I tried a random test case
1 3 9 0 9
It is going in an infinite loop as your while is never terminating.
But your approach is absolutely correct .
The problem can be solved using two approaches:
1 .Read about Comparator Class in Java.
2.Write your own bubble sort which will compare using a function.

I actually used bubble sort only. But instead of comparator class, I typed the whole condition within the nested loop itself.

https://ide.codingblocks.com/s/109685 Please see this. Earlier I had not accounted for equal numbers in the array. i.e two 9s in your case. Please find out a wrong answer case.

@rishabhsetiya7
1 2 98 9 here is your test case.
thankyou.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.