#include <algorithm>
#include <iostream>
#include <vector>
static bool comp(int a, int b)
{
//lambda function evaluates to true - no swap,
//evaluates to false -swap
if(a==0) return false;
if(b==0) return true;
//if neither a nor b is 0 them do not swap
return false;
}
void moveZeros(std::vector<int>& nums)
{
std::stable_sort(nums.begin(),nums.end(),comp);
}
int main(int argc, char** argv)
{
std::vector<int> vec = {0,14,0,3,12};
moveZeros(vec);
for(auto v : vec)
std::cout << v << ' ';
std::cout << '\n';
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKc3RhdGljIGJvb2wgY29tcChpbnQgYSwgaW50IGIpCnsKICAgIC8vbGFtYmRhIGZ1bmN0aW9uIGV2YWx1YXRlcyB0byB0cnVlIC0gbm8gc3dhcCwgCiAgICAvL2V2YWx1YXRlcyB0byBmYWxzZSAtc3dhcAogICAgaWYoYT09MCkgcmV0dXJuIGZhbHNlOwogICAgaWYoYj09MCkgcmV0dXJuIHRydWU7CiAgICAvL2lmIG5laXRoZXIgYSBub3IgYiBpcyAwIHRoZW0gZG8gbm90IHN3YXAKICAgIHJldHVybiBmYWxzZTsKfQoKdm9pZCBtb3ZlWmVyb3Moc3RkOjp2ZWN0b3I8aW50PiYgbnVtcykKewogICAgc3RkOjpzdGFibGVfc29ydChudW1zLmJlZ2luKCksbnVtcy5lbmQoKSxjb21wKTsKfQoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIqKiBhcmd2KQp7CglzdGQ6OnZlY3RvcjxpbnQ+IHZlYyA9IHswLDE0LDAsMywxMn07Cgltb3ZlWmVyb3ModmVjKTsKCQoJZm9yKGF1dG8gdiA6IHZlYykKCQlzdGQ6OmNvdXQgPDwgdiA8PCAnICc7CglzdGQ6OmNvdXQgPDwgJ1xuJzsKfQ==