#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

class A {
    int a;
public:
    A(int a) : a(a) {}
    int getA() const { return a; }
    void setA(int a) { this->a = a; }
    bool operator<(const A & b) const { return a<b.a; }
};

struct myprinter { 
    void operator()(const A & a) { cout << a.getA() << ", "; }  
};

struct doubler {
    void operator()(A& a) { a.setA(a.getA()*2); }
};

int main() {
    int mynumbers[] = {8, 9, 7, 6, 4, 1};
    vector<A> s1(mynumbers, mynumbers+6);
    std::sort(s1.begin(), s1.end());
    for_each(s1.begin(), s1.end(), doubler());
    for_each(s1.begin(), s1.end(), myprinter());
    return 0;
}