So, I've been tweaking some of my program, and I am getting stuck in an infinite loop and this is because I'm not decrementing my recursive function by one, I know this. However, when I am calling my remove function inside my sort function, shouldn't the size of the vector be decrementing by one each time?! I don't understand why I'm getting caught up in an infinite loop....can someone try to fix my code for me please!!!

Code:

int numbers::remove(int index)
{
if ((index >= 0) && ((index + 1) <= numbers.size()))
{
numbers.erase(numbers.begin() + index);
for (int i = 0; i < numbers.size(); i++)
cout << numbers[i] << " ";
}
else
{
cout << "Invalid index, element either below zero or has exceeded the size of the array";
exit(1);
}
}
vector <int> numbers::sort(vector <int> unsorted_list)
{
int i = 1;
if(unsorted_list.size() == 1)
{
cout << unsorted_list.at(0);
exit(1);
}
else
{
int temp;
for (int i = unsorted_list.size() - 1; i >= 0; i--) // Reading the dataset starts backwards.
{
for (int j = 0; j < unsorted_list.size() - 1; j++)
{
if (unsorted_list[j] > unsorted_list[j+1]) //Switching values to maximize convenience.
{
temp = unsorted_list[j];
unsorted_list[j] = unsorted_list[j+1];
unsorted_list[j+1] = temp;
}
}
}
numbers::remove(unsorted_list.size() - 1);
for (int k = unsorted_list.size() - 1; k >= 0; k--)
cout << unsorted_list[k] << " ";
numbers::sort(unsorted_list);
}
}

Thanks for all of the help!!! If you need more code to look at, let me know. Thanks again!