Ensure sanely ordered keys from query