My Program contains 4 arrays and I want to sort the array in such a way that if one array is sorted the other array should follow it
Example:
unsorted array
name code salary date
John 52 6500 15
Suzzy 10 1500 20
Mike 20 1451 16
Sorted array(according to date)
name code salary date
Suzzy 10 1500 20
Mike 20 1451 16
John 10 6500 15
How can I do this type of sorting....?
#include<stdio.h>
#include<conio.h>
struct employ
{
char name[20];
int code;
int salary;
int date;
};
void main()
{
int i;
struct employ e[5];
printf("Enter Details\n");
printf("As per the format given below\ncode,name,salary,date\n");
for(i=0;i<5;i++)
{
printf("\n");
printf("No.%d\n",i+1);
scanf("%d",&e[i].code);
scanf("%s",&e[i].name);
scanf("%d",&e[i].salary);
scanf("%d",&e[i].date);
}
printf(" -----------------------------------------------\n");
printf("| code| Name | Salary | Date |\n");
printf(" -----------------------------------------------\n");
for(i=0;i<5;i++)
{
printf("| %-4d|",e[i].code);
printf(" %-20.20s|",e[i].name);
printf("Rs.%6d |",e[i].salary);
printf("%-8d|\n",e[i].date);
}
printf(" -----------------------------------------------\n");
getch();
}