Replace sortBy intermediate array with CloudArray