Alphabetically sort a vector

I am trying to sort a vector and for some reason all it is doing is flipping the values. I looked over it several times and have been messing with it but with no success. Let me know if you see something wrong or something I may need to add, Thanks!


for(int x=0;x<4;x++){
temp=(*name)[x];
os<<temp;
os>>ida;
os>>fnamea;
os>>lnamea;
for(int y=x+1; y<4; y++){
temp=(*name)[y];
os<<temp;
os>>idb;
os>>fnameb;
os>>lnameb;
if(lnamea>lnameb){
(*name)[y]=(*name)[x];
(*name)[x]=temp;
temp=(*userid)[x];
(*userid)[x]=(*userid)[y];
(*userid)[x]=temp;
}
Can you show the full function signature so we have an idea about what the types are? And please put the code inside [code] tags.
Topic archived. No new replies allowed.