Sort resolved specifications. Fixes #907.