redo sort and paginate

remade the commit, sorry for all the hassle