when you call this function, a is passed by value - that means a copy of the vector is passed to the function, not the vector itself. All the changes (sorting) you make within the function are gone when you return from the function, your original vector is unchanged. I suggest you modify your function to accept a reference instead, it's actually a 1 character change :-)