I have a variable that contains an integer number with the condition that the number 0 (zero) in the variable is a separator between one number and another. The numbers will be separated and sorted based on the numbers in the numbers themselves. After that, the ordered numbers will be combined again without a separator with the output in the form of an integer number.
So example:
dividerSort(74108520159);
the output I want is
147258159
but my output is:
112455789
This is so far I try, hope you can help me figure out
function dividerSort(num){
const divider = 0
let getNum = Array.from(String(num), Number)
getNum = getNum.filter(item =>{
return item !== divider
})
getNum = getNum.sort()
getNum = getNum.join('');
console.log(getNum);
}
dividerSort(74108520159);