Warm tip: This article is reproduced from stackoverflow.com, please click
sorting bubble-sort selection-sort

Integer Sorting Algorithms

发布于 2020-04-04 10:14:51

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?

Questioner
Michele La Ferla
Viewed
39
satya sai 2020-01-31 22:27

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