-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsort.h
59 lines (57 loc) · 1.33 KB
/
sort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
void print_file(contact s[])
{
int i;
printf("\n");
for(i=0; i<count; i++)
{
printf("Contact [#%d]\n Last name: %s\n First name: %s\n ", i+1, s[i].lastname, s[i].firstname);
printf("Date of Birth: %d-%d-%d\n ", s[i].dob.day, s[i].dob.month,s[i].dob.year);
printf("Address: %s\n E-mail: %s\n Phone Number: %s\n\n", s[i].adress, s[i].email, s[i].number);
}
}
void sort_Lname(contact s[])
{
int i,j;
contact temp;
for (i=0; i<=count-1; i++)
{
for (j=i+1; j<=count-1; j++)
{
if (strcasecmp(s[i].lastname,s[j].lastname)==1)
{
#include "swap_alg.h"
}
}
}
print_file(s);
}
void sort_DOB(contact s[])
{
int i, j;
contact temp;
for (i=0; i<count; i++)
{
for (j=i+1; j<count; j++)
{
if (s[i].dob.year>s[j].dob.year)
{
#include "swap_alg.h"
}
else if (s[i].dob.year==s[j].dob.year)
{
if (s[i].dob.month>s[j].dob.month)
{
#include "swap_alg.h"
}
else if (s[i].dob.month==s[j].dob.month)
{
if (s[i].dob.day>s[j].dob.day)
{
#include "swap_alg.h"
}
}
}
}
}
print_file(s);
}