tags:

views:

526

answers:

3

I couldn't find any definitive answer to this question.

I suppose most implementation use merge sort that is stable but, is the stability a requirement or a side effect?

+11  A: 

Yes, std::list<>::sort is guaranteed to be stable.

See http://www.sgi.com/tech/stl/List.html

dalle
Exactly what I was looking for, thanks!
Edouard A.
+8  A: 

According to "The C++ Programming Language" (Stroustrup p470), yes, stl::list<>::sort is stable.

Miles
Quote from source: +1
dalle
+9  A: 

C++ Standard ISO/IEC 14882:2003 says:

23.2.2.4/31

Notes: Stable: the relative order of the equivalent elements is preserved. If an exception is thrown the order of the elements in the list is indeterminate.

Paul
+1. SGI and Stroustrup are both correct but not the "definitive answer". ISO 14882 is.
MSalters
+1 - welcome to stackoverflow :)
Dominic Rodger
Only great answers but I admit this is the best. ;)
Edouard A.