113. Searching and Sorting-I

Question.8

A firmware engineer writes this code to order sensor readings:

typedef struct { uint8_t id; int16_t value; } Sensor;

void sort_sensors(Sensor arr[], int n) {
   for (int i = 0; i < n - 1; i++) {
       for (int j = 0; j < n - i - 1; j++) {
            if (arr[j].value > arr[j+1].value) {
                Sensor temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
       }
   }
}

What algorithm is this, and what is it sorting by?

Need Help? Refer to the Quick Guide below

Select Answer