Sorting Strings Example
Author |
Message |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: 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) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Mon Oct 24, 2005 2:39 pm Post subject: (No 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. |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Mon Oct 24, 2005 6:02 pm Post subject: (No 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? |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon Oct 24, 2005 6:33 pm Post subject: (No 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? |
|
|
|
|
![](images/spacer.gif) |
beard0
![](http://ugray.be/compsci/silly.gif)
|
Posted: Mon Oct 24, 2005 8:58 pm Post subject: (No 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. |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Wed Oct 26, 2005 1:38 pm Post subject: (No 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) ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|