Can I differentiate $$(\pmb{y}^o - (\pmb{x}\cdot\pmb{a})^o)^\top(\pmb{y}^o - (\pmb{x}\cdot\pmb{a})^o)$$ with respect to $\pmb{a}$? (I want to minimize the expression with respect to $\pmb{a}$.)
Here, $\pmb{y}^o$ means the ordered vector of $\pmb{y}$. For example, if $\pmb{y} = (2,9,1)^\top$, then $\pmb{y}^o = (1,2,9)^\top$ and $\pmb{x}\cdot\pmb{a} = (a_1x_1, \ldots, a_nx_n)^\top$.
Try: I wrote the vector $(\pmb{x}\cdot\pmb{a})^o$ as $\pmb{R}\pmb{x}\cdot\pmb{a}$, where $\pmb{R}$ is a matrix that keeps record of the orders. For the above example, it would be $$\pmb{R}=\begin{pmatrix} 0 & 0 & 1\\ 1 & 0 & 0\\ 0 & 1 & 0 \end{pmatrix}.$$ Then I can differentiate the expression w.r.t. $\pmb{a}$. However, the result comes in terms of $\pmb{R}$, which is unknown. (The solution for $\pmb{a}$, that minimizes the given expression, should come in terms of $\pmb{x}$ and $\pmb{y}$.)