Fix a regression in scheduler entry ordering, and add a regression test for it.