2
I have a txt file with about 3000 name entries on each line. I want to list them in alphabetical order.
Is there any way I can do this via some text editor so that i don't have to manually go through all the names in the list?
2
I have a txt file with about 3000 name entries on each line. I want to list them in alphabetical order.
Is there any way I can do this via some text editor so that i don't have to manually go through all the names in the list?
1
You can use a simple command that's included with Windows XP (as that's what I'm assuming you're running from your tag) called sort
.
It's as simple as running sort FileToSort.txt /o OutputFile.txt
in cmd
[replacing FileToSort.txt
with the file you want sorted and OutputFile.txt
with the name of the file you want to output] (start -> run -> cmd; see here for more examples and usage).
0
If you want to write a program...
pseudocode (assumes each name is on its own line):
names as List of Strings
while(!file.eof)
{
names.Add(file.readline());
}
names.Sort();
this would be a better fit if the question were asked on SO. just a thought. – squircle – 2010-04-02T00:28:14.207
You know, I have been using Windows for years and years. I knew about the Unix sort command, uniq, etc. but never once thought to try it on Windows! – Joshua – 2010-04-02T00:59:31.380
"sort in.txt out.txt" doesn't work. You'll need to use "sort in.txt /o out.txt" or "sort in.txt > out.txt" – Bavi_H – 2010-04-02T01:07:02.100
@Bavi_H: Thanks, answer revised to reflect your comment. – squircle – 2010-04-02T15:12:52.600