I need help about creating bubble sort in UiPath Studio Community Edition.
So i have “Input Dialog” for user to input any numbers, but i want after the user click ok/press enter…, the system show the bubble sorted numbers from the number they input.
Example :
They input : 54312
The sort result must be : 12345 (But In Bubble Sort Algorithm)
Bubble Sort is the simplest sorting algorithm that works by *repeatedly swapping the adjacent elements if they are in the wrong order, you can try this code:
void selection_sort(int arr[], int n) {
int i, j, min_idx;
// Traverse through all array elements
for (i = 0; i < n - 1; i++) {
// Find the minimum element in the unsorted part of the array
min_idx = i;
for (j = i + 1; j < n; j++) {
if (arr[j] < arr[min_idx]) {
min_idx = j;
}
}
// Swap the found minimum element with the first element
int temp = arr[min_idx];
arr[min_idx] = arr[i];
arr[i] = temp;
}
}
You can run this code and hope this will help you.