-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsorting.c
57 lines (45 loc) · 1.14 KB
/
sorting.c
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
#include "header.h"
int stringByName(void *one, void *two)
{
char *a;
char *b;
a = (char *)((t_list *)one)->content;
b = (char *)((t_list *)two)->content;
return strcmp(a, b);
}
int byName(void *one, void *two)
{
fileInfo *a;
fileInfo *b;
a = (fileInfo *)((t_list *)one)->content;
b = (fileInfo *)((t_list *)two)->content;
return strcmp(a->name, b->name);
}
int byNameRev(void *one, void *two)
{
fileInfo *a;
fileInfo *b;
a = (fileInfo *)((t_list *)one)->content;
b = (fileInfo *)((t_list *)two)->content;
return strcmp(b->name, a->name);
}
int byTime(void *one, void *two)
{
fileInfo *a;
fileInfo *b;
long dif;
a = (fileInfo *)((t_list *)one)->content;
b = (fileInfo *)((t_list *)two)->content;
dif = (b->seconds - a->seconds);
return (dif == 0) ? (b->nano - a->nano) : (int)dif;
}
int byTimeRev(void *one, void *two)
{
fileInfo *a;
fileInfo *b;
long dif;
a = (fileInfo *)((t_list *)one)->content;
b = (fileInfo *)((t_list *)two)->content;
dif = (a->seconds - b->seconds);
return (dif == 0) ? (a->nano - b->nano) : (int)dif;
}