Search code examples
sortingbubble-sortselection-sort

Integer Sorting Algorithms


I would like to know what kind of sorting algorithm is the one below. I understand that it is a integer sorting algorithm but other than that I haven't figured it out:

void mySorter(int arr[]) {
    int a = arr.length;

    for (int i = 0; i < a-1; i++) {
        int min = i;

        for (int j = i +1 ; j < a; j++) {
            if (arr[j] < arr[min])
                min = j;
            int temp = arr[min];
            arr[min] = arr[i]
            arr[i] = temp;
        }
    }     
}

Could it be a selection sort?


Solution

  • It is Bubble Sort. Your code sorts the list in ascending order.