So you have randomly ordered sequence of digits and you want to sort them? If so, convert your number into discrete chunks (either a string or some type of an array), then use your favorite sorting...