Can we order random variables in a measurable way in a general setup? Let


*

*$(\Omega,\mathcal A,\operatorname P)$ be a probability space

*$(E,\mathcal E)$ be a measurable space

*$n\in\mathbb N$

*$X_1,\ldots,X_n$ be $(E,\mathcal E)$-valued random variables on $(\Omega,\mathcal A,\operatorname P)$

I'm interested in the following question: Given a total$^1$ order $\le$ on $E$, I want to construct $(E,\mathcal E)$-valued random variables $X_{1:n},\ldots,X_{n:n}$ on $(\Omega,\mathcal A,\operatorname P)$ such that $X_{k:n}$ is the $k$th smallest element among $X_1,\ldots,X_n$ (where $X_i$ is considered as smaller than $X_j$ whenever $X_i=X_j$ and $i<j$).

I would like to define them by something like $X_{1:n}:=\min\left\{X_1,\ldots,X_n\right\}$ and $$X_{i:n}:=\min\left\{X_j:X_j>X_{i-1:n}\right\}\;\;\;\text{for }j\in\left\{2,\ldots,n\right\}\tag1,$$ but this won't be well-defined if not all $X_i$ are distinct and it won't be measurable in general. Equivalently, we may ask if there is a random permutation $\pi:\Omega\times\left\{1,\ldots,n\right\}\to\left\{1,\ldots,n\right\}$ such that $X_{\pi(1)}\le\cdots\le X_{\pi(n)}$ and each $X_{\pi(k)}$ is measurable.
The examples I've got in mind include $E=\mathbb R$ with the usual order or $E=\mathbb R^d$ and the order given by the smallest distance to a fixed element $x\in\mathbb R^d$.

Which conditions on the relation between $\mathcal E$ and $\le$ do we need to impose and how do we actually need to define $X_{k:n}$ (or $\pi$)?


$^1$ I've strengthen the assumption from "partial" order to total order, since at least the examples I've described are total orders. Actually, I think we need a total order, since otherwise we cannot use the fact that a finite set has a unique minimum. Please correct me if I'm wrong (I'm not familiar with general order theory) and feel free to weaken the assumption again, if your answer doesn't need the stronger assumption.
 A: $\newcommand{\om}{\omega}
\newcommand{\Om}{\Omega}
\newcommand{\eq}{\,\overset\om\sim\,}
\newcommand{\eqq}{\overset{\,\colon\om}\sim\,}
\renewcommand{\eq}{\,\sim_\om\,}
\newcommand{\K}{\mathcal K}
$
If $E$ is a distributive lattice  with measurable binary operations $E\times E\ni(x,y)\mapsto x\wedge y\in E$ and $E\times E\ni(x,y)\mapsto x\vee y\in E$, then the "order statistics'' $X_{n:j}$ can be defined by the formula 
\begin{equation}\label{eq:wedge-vee}
 X_{n:j}(\om):=\bigwedge\Big\{\bigvee_{i\in J}X_i(\om)\colon J\in\binom{[n]}j\Big\} 
=\bigvee\Big\{\bigwedge_{i\in J}X_i(\om)\colon J\in\binom{[n]}{n+1-j}\Big\}
\end{equation}
for $j\in[n]:=\{1,\dots,n\}$ and $\om\in\Om$, with $\binom{[n]}j$ denoting the set of all subsets $J$ of the set $[n]$ such that the cardinality of $J$ is $j$; cf. formulas (1.2)--(1.4). 
As explained in that paper in the paragraph right after (1.4), if $E$ is not a distributive lattice, then the two dual to each other natural expressions for $X_{n:j}$ in the above display may differ from each other, and thus no reasonable definition of $X_{n:j}$ will seem possible. 

I did not define a permulation $\pi$ in the above answer, which was given for your initial post with only a partial order, and in that general case such a permutation will not exist in general. However, after you added the total order assumption, a measurable random permutation $\pi$ that you want does exist and can be formally described as follows. 
For each $\om\in\Om$, define the equivalence relations $\eq$ over the set $[n]$ by the formula
\begin{equation}
 k\eq l\iff X_{n:k}(\om)=X_{n:l}(\om)  
\end{equation}
for $k,l$ in $[n]$. 
Let then $\K(\om)$ be the set of all $\eq$-equivalence classes. For each $\om\in\Om$ and each $K\in\K(\om)$, let 
\begin{equation}
 I_K(\om):=\{i\in[n]\colon X_i(\om)=X_{n:k}(\om)\ \forall k\in K\}
 =\{i\in[n]\colon\exists k\in K\  X_i(\om)=X_{n:k}(\om)\},  
\end{equation}
so that the cardinality of the set $I_K(\om)$ equals that of $K$, 
and then define the bijection $\rho_K(\om)\colon K\to I_K(\om)$ by the formula
\begin{equation}
 K\ni k\mapsto\rho_K(\om)(k)
 :=\bigwedge\Big\{\bigvee_{i\in J}i\colon J\in\binom{I_K(\om)}{k-m_K+1}\Big\}\in I_K(\om), 
\end{equation}
where $m_K:=\min K$. 
Finally, let 
\begin{equation}
 \pi(\om)(k):=\rho_K(\om)(k)\quad\text{if}\quad k\in K\in\K(\om). 
\end{equation}
Then $\pi\colon\Om\to S_n$ (where $S_n$ is the set of all permutations of the set $[n]$) is a random permutation, which is measurable, because it is defined by composing the measurable random maps $X_{n:k}$ and $X_i$ with other measurable maps. We also have 
\begin{equation}
 X_{n:k}(\om)=X_{\pi(\om)(k)}(\om) 
\end{equation}
for all $k\in[n]$ and all $\om\in\Om$. 
Finally, for all $j,k$ in $[n]$ and all $\om\in\Om$ we have the implication 
\begin{equation}
 (X_{n:j}(\om)=X_{n:k}(\om)\ \&\ j<k)\implies\pi(\om)(j)<\pi(\om)(k), 
\end{equation}
as desired. 

To illustrate the above description/construction of $\pi$, suppose that $n=6$ and $\om\in\Om$ is such that 
\begin{equation}
 (X_i(\om))_1^6=baacba:=(b,a,a,c,b,a) 
\end{equation}
for some $a,b,c$ in $E$ such that $a<b<c$. Then 
\begin{equation}
 (X_{n:k}(\om))_1^6=aaabbc, 
\end{equation}
\begin{equation}
 \K(\om)=\{\{1,2,3\},\{4,5\},\{6\}\}, 
\end{equation}
\begin{equation}
 I_{\{1,2,3\}}(\om)=\{2,3,6\},\ I_{\{4,5\}}(\om)=\{1,5\},\ I_{\{6\}}(\om)=\{4\},\ 
\end{equation}
$\rho_{\{1,2,3\}}(\om)=(236)$ (meaning 
\begin{equation}
 \rho_{\{1,2,3\}}(\om)(1)=2, \rho_{\{1,2,3\}}(\om)(2)=3, \rho_{\{1,2,3\}}(\om)(3)=6),  
\end{equation}
\begin{equation}
 \rho_{\{4,5\}}(\om)=(15),\quad \rho_{\{6\}}(\om)=(4), 
\end{equation}
and 
\begin{equation}
 \pi(\om)=(236154),  
\end{equation}
meaning
\begin{equation}
 (\pi(\om)(1),\dots,\pi(\om)(6))=(2,3,6,1,5,4). 
\end{equation}
