Say you have an integer denoted as $n$. Is it possible to make a purely mathematical function that could take $n$ and order its digits from least to greatest?
I know how to do this programatically. I would simply break the integer up into a list composed of its digits, then iterate through that list with a for loop that compares the digits, and so on and so forth.
However, how could I do this without any data structures, manipulating $n$ only mathematically?
EDIT:
When I say manipulating $n$ only mathematically, I mean with arithmetic only. No breaking it up into a list or anything similar.
$$ f(n) = \min\left\{\sum_{k=0}^{n-1} a_{\sigma(k)} 10^k\colon \sigma\in\Sigma_n,\ \sum_{k=0}^{n-1} a_k 10^k = n,\ a_k\in\{0,1,2,3,4,5,6,7,8,9\}\right\} $$ where $\Sigma_n$ is the set of permutations of $\{0,1,\dots,n-1\}$.