Python bar plot sorting multiple results of multiple traces

I have created a python bar plot with multiple traces. But I am having trouble sorting the end result according to their position on the y-axis.

The plot describes the results of a prediction algorithm. Three traces describe correct predictions, over_estimations, and under_estimations. In order to create the traces I created three copies of original list of samples and update them with NaN to indicate where they are not what suppose to be represented by their respective trace, e.g to create the correct prediction series, I assign NaN to those samples that are predicted incorrectly. I then create bar chart, but the x-axis ordered according original list of samples. I would like to sort it according their height on the y-axis. Please note I think the sort operation has to be done in layout where the traces have been merged; if done in the traces themselves the traces will no longer be aligned.

For an example of the unsorted plot see