함수 solution은 정수 n을 매개변수로 입력받습니다. n의 각 자릿수를 큰것부터 작은 순으로 정렬한 새로운 정수를 리턴해주세요. 예를들어 n이 118372면 873211을 리턴하면 됩니다.
n은 1이상 8000000000 이하인 자연수입니다.

import java.util.Arrays;
class Solution {
public long solution(long n) {
int len = 0;
long temp = n;
while (n != 0){
n /= 10;
len++;
}
long[] arr = new long[len];
long answer = 0;
for (int i = 0; i<len; i++){
arr[i] = temp / (long)Math.pow(10, len-i-1);
temp = temp % (long) Math.pow(10, len-i-1);
}
Arrays.sort(arr);
for (int i=0; i<len; i++){
answer += arr[i] * (long)Math.pow(10,i);
}
return answer;
}
}

