Your task is to make a function that can take any non-negative integer as a argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible number.
public class DescendingOrder {
public static int sortDesc(final int num) {
String a=String.valueOf(num);
int[] b=new int[a.length()];
int c=0;
String d="";
for(int i=0;i<a.length();i++){
b[i] = Integer.parseInt(a.charAt(i) + "");
}
int max;
int o;
for(int i=0;i<b.length-1;i++){
max=i;
for(int j=i+1;j<b.length;j++){
if(b[j]>b[max]){
max=j;
}
}
if(max != i){
o=b[max];
b[max]=b[i];
b[i]=o;
}
}
for(int i=0;i<a.length();i++){
d=d+b[i];
}
int e = Integer.parseInt(d);
return e;
}
}
https://www.codewars.com/kata/5467e4d82edf8bbf40000155/train/java