You are providing a bit too little info to answer that.
Most probably you have out-of-bounds accesses. For example, is sort resized to UsedSpace.
Anyway, if this is meant for merging two vectors, you'll need to figure out the algorithm first (for example, on paper).
Something like this (X marks past end of array, if any of the pointers reaches that, you'll need to figure out something in addition):
Code:
1 2 5 X
^
a
3 4 7 X
^
b
a points to smaller. Pick *a and advance a.
1 2 5 X
^
a
3 4 7 X
^
b
1
a still points to smaller. Pick *a and advance it again.
1 2 5 X
^
a
3 4 7 X
^
b
1 2
Now b points to a smaller value. Pick *b and advance it.
1 2 5 X
^
a
3 4 7 X
^
b
1 2 3
etc.