-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsort_students.cpp
More file actions
78 lines (77 loc) · 1.64 KB
/
sort_students.cpp
File metadata and controls
78 lines (77 loc) · 1.64 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "main.hpp"
bool alpha_cmp(student a, student b)
{
return a.get_name() < b.get_name();
}
bool DOB_cmp(student a, student b)
{
return a.getDOB() < b.getDOB();
}
bool DOJ_cmp(student a, student b)
{
return a.getDOJ() < b.getDOJ();
}
bool enrollment_cmp(student a, student b)
{
if(a.get_year() == b.get_year())return a.get_enrollment() < b.get_enrollment();
else return a.get_year() < b.get_year();
}
bool alpha_cmp_rev(student a, student b)
{
return b.get_name() < a.get_name();
}
bool DOB_cmp_rev(student a, student b)
{
return b.getDOB() < a.getDOB();
}
bool DOJ_cmp_rev(student a, student b)
{
return b.getDOJ() < a.getDOJ();
}
bool enrollment_cmp_rev(student a, student b)
{
return !enrollment_cmp(a,b);
}
bool year_cmp(student a, student b)
{
if (a.get_year() == b.get_year())
return a.get_name() < b.get_name();
else
return a.get_year() < b.get_year();
}
void alpha_sort(vector<student> &v)
{
sort(v.begin(), v.end(), alpha_cmp);
}
void DOB_sort(vector<student> &v)
{
sort(v.begin(), v.end(), DOB_cmp);
}
void DOJ_sort(vector<student> &v)
{
sort(v.begin(), v.end(), DOJ_cmp);
}
void enroll_sort(vector<student> &v)
{
sort(v.begin(), v.end(), enrollment_cmp);
}
void alpharev_sort(vector<student> &v)
{
sort(v.begin(), v.end(), alpha_cmp_rev);
}
void DOBrev_sort(vector<student> &v)
{
sort(v.begin(), v.end(), DOB_cmp_rev);
}
void DOJrev_sort(vector<student> &v)
{
sort(v.begin(), v.end(), DOJ_cmp_rev);
}
void enrollrev_sort(vector<student> &v)
{
sort(v.begin(), v.end(), enrollment_cmp_rev);
}
void yearsort(vector<student> &v)
{
sort(v.begin(), v.end(), year_cmp);
}