Server side of sorting working