Skip to content

Instantly share code, notes, and snippets.

@XChrisUnknownX
Created October 15, 2018 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XChrisUnknownX/0a3669dd955120a52819f0b720dd960b to your computer and use it in GitHub Desktop.
Save XChrisUnknownX/0a3669dd955120a52819f0b720dd960b to your computer and use it in GitHub Desktop.
#If the program works correctly you should be able to give it a txt with a word on each line and it should give you a new txt with the words sorted alphabetically.
#It should also theoretically give a list of all the words at the end.
#Use chammy.txt to test.
filename = input("Specify txt you wish to sort: ")
with open(filename,"r") as sortfile, open("Sorted File.txt","x") as newfile:
newlist = []
for line in sortfile:
item = sortfile.readline()
newlist.append(item)
newlist.sort()
counter = 0
while counter < len(newlist):
newfile.write(newlist[counter])
counter += 1
newfile.write(newlist+"\n")
walrus
makeup
realize
artichoke
amnesty
gamer
play
pork
hand
land
fanned
cramped
joker
box
go
try
mark
fall
lose
loser
start
restart
preliminary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment