Use shared_ptr in TopSorter