updated _get_all_iders to use sorting from sql