I've used the following code -
x[][] is the array to be sorted
void sort() {
int max1, max2, s;
for (int i = 0; i < row; i++) {
for (int j = 0; j < column; j++) {
max1 = i;
max2 = j;
for (int k = i; k < row; k++) {
if (k == i) { // need to improve this part
for (int l = j; l < column; l++) {
if (x[k][l] > x[max1][max2]) {
max1 = k;
max2 = l;
}
}
} else {
for (int l = 0; l < column; l++) {
if (x[k][l] > x[max1][max2]) {
max1 = k;
max2 = l;
}
}
}
}
s = x[max1][max2];
x[max1][max2] = x[i][j];
x[i][j] = s;
}
}
}
I want to remove the if else statement or is this another way to do it using selection sort?
(I know there are simpler ways to do this but I'm trying to do it with selection sort)