sending the sorted array to client