Fix constraint sorting