The title speaks for itself ….
Does choice of container affects the speed of the default std::sort algorithm somehow or not? For example, if I use list, does the sorting algorithm just switch the node pointers or does it switch the whole data in the nodes?
I don’t think
std::sortworks on lists as it requires a random access iterator which is not provided by alist<>. Note thatlist<>provides asortmethod but it’s completely separate fromstd::sort.The choice of container does matter. STL’s
std::sortrelies on iterators to abstract away the way a container stores data. It just uses the iterators you provide to move elements around. The faster those iterators work in terms of accessing and assigning an element, the faster thestd::sortwould work.