This problem occurs because the way that workworks functions like QUERY, IMPORTRANGE, among others, that returnreturns an array of values instead of single values. While we see each value on different cells, they actually are "tied" together.
To avoid this problem, we should not sort manually the results of formula because, as the OP already found, "results are unpredictable".
If you are using QUERY you could use ORDER BY clause to sort values. Another alternative that keepkeeps the reference to the source range is to use nest QUERY inside a SORT function.
In some cases, doing a copy / paste / manipulate data and repeat could be the better approach.