Obey sort order

Replaces #698