var s = '18013820100';
var arr = Array.from(new Set(s.split(''))).map(i => parseInt(i)).sort(function (a,b) {return b-a });
var kv = {};
arr.forEach((v, index) => { kv[v] = index });
var index = [];
s.split('').forEach(v => { index.push(kv[v]) });
console.log(arr,index)