Does the standard guarantee that order of equal elements will not change (eh, forgot the term for that) by using std::sort or do I need to consider an alternative solution
From C++ reference: here
Elements that would compare equal to each other are not guaranteed to keep their original relative order.
You might want stable_sort, but note that it's not as fast (in average)