I wanted to take the values from user and wanted to sort it... so i took values in two arrays one in string array and the other in int array... if i sort the string array it get sorted very well.. i m not able to sort the int array accordingly.... but its still not working ...i hope u guys can help
so i searched net and tried using the pair function from STL
void sortItems(char array[][10],int y[],int n){
pair<char,int>pairt[n];
for (int i = 0; i < n; i++)
{
pairt[i].first = array[i][10];
pairt[i].second = y[i];
}
char t[20];
int i,j,k,p=1;
for(i=1; i<=n; i++)
{
for(j=1; j<11; j++)
{
if(strcmp(pairt[j-1], pairt[j])>0)
{
strcpy(t, pairt[j-1]);
strcpy(pairt[j-1], pairt[j]);
strcpy(pairt[j], t);
p=i;
}
}
}
std::cout<<"Dokemon in alphabetical order : \n";
for(i=1; i<=n; i++)
{
std::cout<<array[i]<<endl;
}
}
[Error] cannot convert 'std::pair' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)'
m getting 4 errors of this type