Computer Science Canada Sorting Strings Example |
Author: | MysticVegeta [ Mon Oct 24, 2005 1:58 pm ] |
Post subject: | Sorting Strings Example |
Hi, Sorry if this has been posted before, i looked thoroughly through the results but didnt find an example of code of sorting strings. Please someone bother to put an example, the DWITE is getting closer, so i need to practise it too! Or someone give ideas/pseudocodes to support!, Thanks a lot! 8) |
Author: | [Gandalf] [ Mon Oct 24, 2005 2:39 pm ] |
Post subject: | |
It works the same as for numbers, just change the value to a string. If you don't know how to sort numbers look up bubble sort, or any other sort method either here or on google. |
Author: | MysticVegeta [ Mon Oct 24, 2005 6:02 pm ] |
Post subject: | |
nono i know how to sort the numbers. I just wanted to see an example of how its done perfectly. If i am correct, is this how you do it? 1) Add the integer values of word for example (ABC = 65+66+67) 2) Do for all words 3) sort the numbers 4) put the corresponding words for the sorted numbers? is this the way do it? |
Author: | Cervantes [ Mon Oct 24, 2005 6:33 pm ] |
Post subject: | |
No! That won't get you anywhere! Well, anywhere you want. Think: ab = 65 + 66 = 131 ba = 66 + 65 = 131 Which comes first, alphabetically? |
Author: | beard0 [ Mon Oct 24, 2005 8:58 pm ] |
Post subject: | |
In Turing, "Hello" < "World" returns true, so you can use the exact same procedure you used to sort numbers, just change the variable type. This is what [Gandalf] was saying. |
Author: | MysticVegeta [ Wed Oct 26, 2005 1:38 pm ] |
Post subject: | |
What the? they had it built in? oh my god! and here i was doing all kind of sorts that zylum or rizzix (not sure) posted in the tutorials. I realize that was silly, and here i was thinking turing was useless, lol (still is) |