sort by id to ensure stable results ordering