forked from RoksYz/CS1301xIII---Data-Structures
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortFilms.py
More file actions
27 lines (24 loc) · 748 Bytes
/
SortFilms.py
File metadata and controls
27 lines (24 loc) · 748 Bytes
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
def sort_films(filename,filedestination):
FileOpen0 = open(filename,"r")
listt = []
for item in FileOpen0:
item0 = item.split("\t")
item1 = item0[1].strip("\n")
listt.append(item1)
listt.sort(reverse=True)
i=0
for i in range(len(listt)):
FileOpen1 = open(filedestination,"a")
for line in open(filename):
line0 = line.split("\t")
line1 = line0[1].strip("\n")
if listt[i]==line1:
print(line0[0]+'\t',line1,file=FileOpen1)
i+=1
break
else:
pass
FileOpen0.close()
#print: "Done!"
sort_films("top500.txt", "top500result.txt")
print("Done!")