friend network and quick sort