Ordering legend items can be done very easily by reordering the elements of p.legend. However, when using a GroupBy Legend, this isn't so straightforward, since the order is computed on the JS side, which can lead to lengthy and manual workarounds.
It would be great if the GroupBy Legends could also be ordered using the same syntax as for non-GroupBy ones.