In C++, it would be advisable to use the STL function std::sort to sort a vector of integers with user-defined sorting criteria. This works best with a lambda function.
The order of conditions is important to ensure that the sorting rules are fulfilled according to the requirements of the task. In ascending sorting, the value considered "smaller" is placed at the front. Returning false means that the relative order is maintained.
std::vector<int> numbers = { 51, -4, 0, 24, -13, -6, 0, 38, -27, -48, 3, 17, 8, 0, 21 };
std::sort(numbers.begin(), numbers.end(), [](int a, int b) {
if (a == b)
return false;
return a < b;
});