Skip to content

Instantly share code, notes, and snippets.

@XChrisUnknownX
Last active October 17, 2018 15:47
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/dce555fced5fdf8c6d84baed195050dd to your computer and use it in GitHub Desktop.
Save XChrisUnknownX/dce555fced5fdf8c6d84baed195050dd to your computer and use it in GitHub Desktop.
Sorts txts that are in the format of chammy.txt or chammy2.txt
#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.
filename = input("Specify txt you wish to sort: ")
with open(filename,"r") as sortfile, open("Sorted File.txt","x") as newfile:
newstring = sortfile.read()
newlist = newstring.split()
newlist.sort()
for n in newlist:
newfile.write(n)
newfile.write("""
""")
walrus
makeup
realize
artichoke
amnesty
gamer
play
pork
hand
land
fanned
cramped
joker
box
go
try
mark
fall
lose
loser
start
restart
preliminary
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