Very stupid question qsort

Can qsort()
http://www.cplusplus.com/reference/clibrary/cstdlib/qsort/

be used with a STL container?let´s say vector of a class?

like in
1
2
3
vector<Trabajador> vector_trabajador;

qsort((void*)(&vector_trabajador),vector_trabajador.size(),sizeof(Trabajador),comparar);
It should work for vectors, but not for lists.
Though you really shouldn't do that. Use http://www.cplusplus.com/reference/algorithm/sort/ instead.
I think you would be better off using std:sort.
thanks
Wouldn´t work for vectors of STL because it´s a function from C library , tought it may work for simple vectors(int or char) wont work if you try with clases.
Kooth: thanks, discovered it and used it and it works just fine

sort(vector_trabajador.begin(),vector_trabajador.end(),compare_function);

Topic archived. No new replies allowed.