0

The aim is to sort the least used digits in ascending order beside 0 :
for example :
87125897! is 7 then 4 then 6 then 9 then 8 then 3 then 5 then 1 and before last 2 (7 being the first means it is the least appearing digit in the result)
87125891! is 1 then 7 then 2 then 6 then 9 then 4 then 8 t...