fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. vector<int> v = {-1, 2, 8, -9, -2, -3, -6, -10, -8, 5, 7, 9, 7};
  9. stable_sort(v.begin(), v.end(), [](int x, int y) { return (abs(x) % 2) > (abs(y) % 2);});
  10. for_each(v.begin(), v.end(), [](int x) { cout << x << ' '; });
  11. return 0;
  12. }
Success #stdin #stdout 0s 4380KB
stdin
Standard input is empty
stdout
-1 -9 -3 5 7 9 7 2 8 -2 -6 -10 -8