Fix order assignment. Fixes #5710