Add proper pagination sorting functionality