#include <vector>
#include <iostream>

template <typename T>
class VectorSort {
    private:
        std::vector<T *> v;
    public:
        VectorSort(std::vector<T> *v) {
            for (long unsigned int i = 0; i < (*v).size(); i++) {
                this->v.push_back(&(*v)[i]);
            }
        };
        
        int sort() { // ist bubble sort
            if (this->v.size() == 0)
                return 0;
            long unsigned int n = this->v.size();
            bool is_sorted = false;
            
            for (long unsigned int i = 0; i < n - 1; i++) {
                is_sorted = true;
                
                for (long unsigned int j = 0; j < n - i - 1; j++) {
                    if (*(this->v[j]) > *(this->v[j + 1])) {
                        std::swap(this->v[j], this->v[j + 1]);
                        is_sorted = false;
                    }
                }
                
                if (is_sorted) {
                    break;
                }
            }
            return 0;
        }
        
        void print() {
            if (this->v.size() == 0)
                return;
            std::cout << "{ ";
            long unsigned int i = 0;
            for (; i < (this->v.size())-1; i++) {
                std::cout << *(this->v[i]) << ", ";
            }
            std::cout << *(this->v[i]) << " }" << std::endl;
        }
};
