https://programmers.co.kr/learn/courses/30/lessons/12933
function solution(n) {
var answer = 0;
var temp = '';
var arr = [];
temp = n.toString();
arr = temp.split('');
arr.sort((a,b) => b-a);
var str =arr.join('');
answer = parseInt(str,10);
return answer;
}
function solution(n) {
var answer = 0;
var convertedN = n.toString();
var arrayOfN = convertedN.split('');
arrayOfN.sort(function(a,b){
if (parseInt(a) <parseInt(b)){
return 1;
}
else if (parseInt(a)>parseInt(b)){
return -1;
}
return 0;
})
answer = parseInt(arrayOfN.join(''));
return answer;
}