Added ordering by id to apis

Without this for rows that have equal date some undefined order occurred.