Author |
Message |
GoodbyeSoberDay1
|
Posted: Mon Mar 24, 2008 5:00 pm Post subject: Importing text and sorting help (or something) |
|
|
Hi,
I need to import a text document into turing and then sort the words in alphabetical order, can anyone tell me how?
P.S I know how to do the importing part |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Mon Mar 24, 2008 5:08 pm Post subject: RE:Importing text and sorting help (or something) |
|
|
You could compare words in the same manner as integer values.
Turing: |
put "Tony comes before Dan alphabetically? ", "Tony" > "Dan"
|
There are a few algorithms to sort things available, but at the most basic level they all just compare words to each other like this. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
A.J
|
Posted: Mon Mar 24, 2008 6:57 pm Post subject: Re: Importing text and sorting help (or something) |
|
|
as for the importing of the info, look up 'read' and 'write' , or file input/output.If you still need help, keep asking away
A.J |
|
|
|
|
|
Yagami_Light
|
Posted: Tue Mar 25, 2008 3:58 pm Post subject: RE:Importing text and sorting help (or something) |
|
|
import each word into a flexible array, then sort it using a sorting algorithm as Tony said (bubble sort is the easiest one for beginners but it might take some time if the document is very long) and export the words from array into a new file. |
|
|
|
|
|
A.J
|
Posted: Tue Mar 25, 2008 7:03 pm Post subject: Re: Importing text and sorting help (or something) |
|
|
if you are importing a HUGE number of words, I suggest you not use bubblesort.
But if you aren't, then bubblesort is the way to go ! |
|
|
|
|
|
GoodbyeSoberDay1
|
Posted: Wed Mar 26, 2008 9:28 am Post subject: Re: Importing text and sorting help (or something) |
|
|
Thanks alot guys, this really helped (well i think still haven't tried it haha). |
|
|
|
|
|
|