Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Importing text and sorting help (or something)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
GoodbyeSoberDay1




PostPosted: 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
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
A.J




PostPosted: 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 Wink

A.J
Yagami_Light




PostPosted: 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




PostPosted: 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 Very Happy!
GoodbyeSoberDay1




PostPosted: 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). Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: