Ho implementato il bubble sort in C++ cosi:
codice:
template<class T>
void sort(vector<T> elementi, int dim)
{
    for(int i=0;i<dim;i++)
    {
       for(int j=0;j<dim-1;j++)
       {
          if(elementi[i] > elementi[j+1])
          {
             T tmp = elementi[i];
             elementi[i] = elementi[j+1];
             elementi[j+1] = tmp;
          }   
       }
    }
}
Come posso migliorarlo?