Since we don't have your entire applicaton, the only I can tell you is to watch the internals of the vector and single step until something changes. Whatever changed the internals of the vector is what is causing the problem.

Otherwise, it could be something totally unrelated to what you posted, i.e. you've corrupted memory somewhere else in your application, and the symptoms are showing up in the sorting.

You should still check for out-of-bounds conditions (such as an empty vector).

Regards,

Paul McKenzie