sorting: stream and rank