-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjobs_sort.c
More file actions
50 lines (46 loc) · 1.22 KB
/
jobs_sort.c
File metadata and controls
50 lines (46 loc) · 1.22 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
#include "Header.h"
#include "sysCommands.h"
void jobs_sort(){
struct bg_prc *temp;
temp = initial;
int count = 0;
struct bg_prc *prev, *curr, *next;
while (temp != NULL){
temp = temp->next;
count++;
}
// printf("%d\n", count);
int i;
for (i = 0; i < count; i++){
curr = initial;
prev = initial;
while (curr->next != NULL){
next = curr->next;
if (curr == initial){
if (strcmp(curr->name, next->name) > 0){
curr->next = next->next;
next->next = curr;
initial = next;
prev = next;
}
else{
curr = curr->next;
prev = initial;
}
}
else{
// break;
if (strcmp(curr->name, next->name) > 0){
curr->next = next->next;
next->next = curr;
prev->next = next;
prev = next;
}
else{
curr = curr->next;
prev = prev->next;
}
}
}
}
}