
-----------------------------------
sensfan
Mon Nov 07, 2005 11:50 am

Sort Words Alphabetically
-----------------------------------
Hey, I'm kind of new to this so I'm not quite sure what to do. How do you sort words alphabetically? I've got very little code written so far because I'm not sure what to use. I really don't know what else to say. Any help would be appreciated - especially if I can get it before 4th period.

--Thanks.

(Senators have the Cup this year...)

-----------------------------------
jamonathin
Mon Nov 07, 2005 12:51 pm


-----------------------------------
You should post what code you do have, no matter how bad it is, that way we can se what we're working with. 

Each letter(character) has a number value.  Look up ord and chr in Turing Reference (F10).  What you can do from there is pick apart the word and see which value the letter(character) is.  Then you can arrange from lowest number to highest.  

*Note* Capital letters have higher values then lower case.  
(i.e  'A' > 'a')

-----------------------------------
codemage
Mon Nov 07, 2005 1:01 pm


-----------------------------------
Turing understands how to compare strings in the same way that it can compare numeric values.  If you can figure out how to sort numeric values, you can do strings.

I may have to do a tutorial on "sorting in Turing" for y'all.

EDIT:  You might be able to glean some help from here:
http://www.compsci.ca/v2/viewtopic.php?t=4091&highlight=bubble+selection

-----------------------------------
Tony
Mon Nov 07, 2005 1:01 pm


-----------------------------------
jamonathin - capital letters actually have a lower value.

put "A" > "a"


false


you could compare whole words as so

put "Tony" > "Dan"


true


sensfan - so just loop through your list of words and compare if one comes before the other, then rearrange them if needed.

-----------------------------------
jamonathin
Mon Nov 07, 2005 2:21 pm


-----------------------------------
jamonathin - capital letters actually have a lower value.

put "A" > "a"


false

Whoops@! lol . .  :all:  .. maybe i should check next time

never knew about that boolean check, meh, learn somethin every day . .

-----------------------------------
MysticVegeta
Mon Nov 07, 2005 2:42 pm


-----------------------------------
"A" = 65
"a" = 97

65 < 97

-----------------------------------
[Gandalf]
Mon Nov 07, 2005 3:40 pm


-----------------------------------
put "zzz" > "aargh"
if "Zzz" > "aargh" then    
    put "This works flawlessly"
else
    put "Now you see the problem with this method"
end if
You must take into account upper/lower case letters while doing this too.  A good way of solving it is by looking up Str.Upper() and/or Str.Lower()

-----------------------------------
jamonathin
Mon Nov 07, 2005 5:19 pm


-----------------------------------
Mod edit: Now now, no need to be snide.  We're all friends here, right?

-----------------------------------
Flikerator
Tue Nov 08, 2005 9:40 am


-----------------------------------
"]put "zzz" > "aargh"
if "Zzz" > "aargh" then    
    put "This works flawlessly"
else
    put "Now you see the problem with this method"
end if
You must take into account upper/lower case letters while doing this too.  A good way of solving it is by looking up Str.Upper() and/or Str.Lower()

Omg thanks, I was looking for that! I made my own functions to do it in some programs, now I can lesson the lines :P

-----------------------------------
beard0
Tue Nov 08, 2005 10:11 am


-----------------------------------
now I can lesson the lines

Here's a lesson for you:  Now you can lessen the number of lines. :P
