-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSorting_CGPA.m
More file actions
executable file
·63 lines (42 loc) · 1.23 KB
/
Sorting_CGPA.m
File metadata and controls
executable file
·63 lines (42 loc) · 1.23 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
function [sorted_details,sorted_txt] = Sorting_CGPA(roll_and_CGPA,txt)
clc;
CGPA = roll_and_CGPA(:,2);
Roll_nos_tobe_sorted = roll_and_CGPA(:,1);
[sorted_CGPA,sort_index] = sort(CGPA,'descend');
%%%%%%%%%%%%%%%%%%%%%% adding seperate column to differentiate same CGPA %%
a = sorted_CGPA;
[ii,~,kk]=unique(a);
repeated=ii(histc(kk,1:numel(ii))>1);
repeated = sort(repeated,'descend');
if repeated > 0
k = 1;
while true
for i = 1: length(a)
for j = i:length(a)
if repeated(k) == a(j)
a(j,2) = k;
end
end
end
k = k + 1;
if k > length(repeated)
break
end
end
clear k
clear repeated
clear i
clear j
else
a(:,2) = 0;
end
sorted_CGPA = a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Roll_nos_CGPA = num_sort(:,Roll_no_column);
sorted_Roll_nos = Roll_nos_tobe_sorted(sort_index,:);
format longG
sorted_details = [sort_index sorted_Roll_nos sorted_CGPA];
txt_without_headings = txt(1:end,:);
sorted_txt = txt_without_headings(sort_index,:);
end
%########################################################################