#include <string.h>
struct A{
int id;
char *name;
}
int compare_A(const struct A* a1, const struct A* a2 ){
if (a1->id > a2-> id)
return 1;
else if (a1->id < a2->id)
return -1;
else{
if(strcmp(a1->name. a2->name) >= 0)
return 1;
else
return -1;
}
}
void sort_A(struct A [] input, unsigned int n){
int i,j;
int temp;
for(i=1;i<n;i++)
{
temp = input[i];
for(j=i ; j>0 && compare_A(temp, input[j-1]) < 0 ; j--)
{
input[j]=input[j-1];
}
input[j+1]=temp;
}
|