MDL-31830 course management: better handling of resorting