Code:
#include <iostream>
#include <cstdlib>
using namespace std;
short employee[16][3]={{2,5,1050},
{5,17,1200},
{3,12,1225},
{2,23,1300},
{3,6,1140},
{3,3,1110},
{2,4,1420},
{2,1,1360},
{5,14,1225},
{5,11,1380},
{5,10,1410},
{2,2,1565},
{3,8,1445},
{5,7,1387},
{3,9,1128},
{2,16,1448}};
void sort_em(short[][3],short);
void showArray();
int main()
{
showArray();
sort_em(employee,16);
cout<<"\n\nNow it is sorted\n";
showArray();
system("PAUSE");
return 0;
}
void sort_em(short array[][3],short elems)
{
short start,minIndex,minValue,tempValue,otherTemp;
for(start=0;start<(elems-1);start++)
{
minIndex=start;
minValue=array[start][0];
tempValue=array[start][1];
otherTemp=array[start][2];
for(short index=start+1;index<elems;index++)
{
if(array[index][0]<minValue)
{
minValue=array[index][0];
tempValue=array[index][1];
otherTemp=array[index][2];
minIndex=index;
}
}
array[minIndex][0]=array[start][0];
array[minIndex][1]=array[start][1];
array[minIndex][2]=array[start][2];
array[start][0]=minValue;
array[start][1]=tempValue;
array[start][2]=otherTemp;
}
}
void showArray()
{
for(short r=0;r<16;r++)
{
for(short c=0;c<3;c++)
{
cout<<employee[r][c]<<" ";
}
cout<<"\n\n";
}
}