The function accepts an array of structure instances and the number of instances, and sorts this array by 2 fields ( nomer and sname ) in descending order, but the sorting does not occur, all the time the same fields are passed to the condition, what is the error?
int SelectSort(contact *buf, int NumEl) { for (int i = 0; i < NumEl - 1; i++) { int i_min = i; for (int j = i + 1; j < NumEl; j++) { if (strncmp(buf[i_min].nomer, buf[j].nomer, 2) >= 0) { if (strcmp(buf[i_min].sname, buf[j].sname) >= 0) i_min = j; } } if (i_min != i) { swap(buf[i], buf[i_min]); } } return 0; }