Code:
{
int array[5][5] = {5,4,8,3,8,9,2,5,4,9,7,6,1,4,3,5,6,3,9,7,8,3,4,2,6};
int temp[5][5] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
cout << "=============UNSORTED============="<< endl;
for (int w=0;w<5;w++){
for (int k=0; k<5 ; k++){
cout << array[w][k] << "\t";
}
cout << endl;
}
cout << "=============SORTED==============" << endl;
for(int i=0; i<5;i++){
for(int j=0; j<5;j++){
if(array[j][0] > array[j+1][0])
{
temp[0][0] = array[j][0];
array[j][0] = array[j+1][0];
array[j+1][0] = temp[0][0];
}
}
}
for (int w=0;w<5;w++){
for (int k=0; k<5 ; k++){
cout << array[w][k] << "\t";
}
cout << endl;
}
}
My output is: