I was motivated for this question while seeking for a new sorting algorithm.
Suppose a continuous function $f : [a, b] \to \mathbb{R}$ is given. I wanted to define the sorted version $g$ of $f$, which shall satisfy the following properties:
- $g$ monotone increases
- $g(a)$ is the global minimum of $f$
- $g(b)$ is the global maximum of $f$
And I eventually came up with the following equation: $$ \int_a^x g = \int_{\{y : f(y) \leq g(x)\}} f $$
And I tried to construct $g$ from $f$ explicitly. Simple argument: Since $\{y : f(y) \leq g(x)\}$ is a closed subset of the compact set $[a, b]$, it is the union of some finitely many closed intervals (and possibly some isolated points), say $[a_1(x) = a, b_1(x)], [a_1(x), b_1(x)], \cdots, [a_n(x), b_n(x) = b]$. That gives the following equation: $$ \int_a^x g = \sum_{k=1}^n\int_{a_k(x)}^{b_k(x)} f $$
By taking the derivative of both sides of the equation above, I get this: $$ g(x) = \sum_{k=1}^n (f(b_k(x)) \cdot b_k'(x) - f(a_k(x)) \cdot a_k'(x)) $$
By definition of $a_k$ and $b_k$, $f \circ a_k = f \circ b_k = g$, and thus: $$ g(x) = \sum_{k=1}^n (g(x) \cdot b_k'(x) - g(x) \cdot a_k'(x)) = \sum_{k=1}^n g(x) (b_k'(x) - a_k'(x)) = g(x) \sum_{k=1}^n (b_k'(x) - a_k'(x)) $$
...which doesn't give any information of $g$. Does this mean this equation is under-determined? Does it even make sense to "sort" a function?
I think what you want is the nondecreasing rearrangement of $f$ on the interval $[a,b]$, which can defined by $$g(x)=\inf\{t :m(\{s \in [a,b]:f(s)>t\})\le x-a\}$$ where $m$ is Lebesgue measure.