This is the function to read words from text file, sort these and then store in another text file.
#file contains words
file=open('/content/gdrive/MyDrive/Post_OCR_Classifictaion/Dict_try.txt').read().split()
#sorting order based on letters
letters="abcçdefgğhıijklmnoöprsştuüvyz"
d={i:letters.index(i) for i in letters}
#sort function
sorted_list=sorted(file,key=d.get)
#store after sortting in new file
textfile = open("/content/gdrive/MyDrive/Post_OCR_Classifictaion/Dict_try_sort.txt", "w")
for element in sorted_list:
textfile.write(element + "\n")
textfile.close()
These are the words in text file:
aço
çzb
ogğ
beg
zğe
öge
ğg
gaço
ogğ
But it gives error: