My bubble sort only sorts once
Hi, i have been endlessly trying to make this bubble sort work. what happens is that i have to manually keep pressing 3 (this is my option to sort the data) for each swap, whereas i want the whole array sorted in one go. The function i have written is part of a CNC menu program where the user enters a number to perform a specific task. My bubble sort is shown below. The problem im having is that it is only swapping 2 numbers, then i press 3 and it sorts again etc. My question is how do i loop the whole thing to sort everything in one go?
EDIT: x is the number of values the user requests to be sorted
void bubblesortascending(float myarray,int x)
printf("To view the sorted data, please press 4 to display the array\n\r");