hi all, i would really appreciate if someone can tell me how to go about making a word sort program in javascript.Its a bit urgent,so quick response will be really helpful.Thanks in advance.
@parvinderauthorApr 18.2008 — #thanks for the reply but actually i am looking for a sort in for word,rather i should put about making a javasript program that will organize words into alphabetical order,for example,there is an word input space and we would enter two or three lines of sentences and then when we will click the sort button the program should sort the words according to vowels or according to the first letter of that word.
@JMRKERApr 18.2008 — #Modify sort for different order or case (upper/lower) displays. [code=php] <html> <head> <title> Word Sorter </title> <script type="text/javascript"> function SortWords() { var warr = new Array(); var words = document.getElementById('src').value; words = words.replace(/n|r/g,' '); warr = words.split(" "); warr.pop(); // drop blank entry at end of input warr = warr.sort(); // modify order, case, etc. if desired return warr.join('n'); } </script> </head> <body> <h1> Word Sorter </h1> Enter words to sort:<br> <textarea id="src" rows="5"> Now is the time for all good men to come to the aid of their country. </textarea> <br> <button id="SortWords" onClick="document.getElementById('dst').value=SortWords()">Sort Words</button> <button id="clr" onClick="document.getElementById('src').value='';document.getElementById('dst').value=''">Clear</button> <br> Sorted order:<br> <textarea id="dst" rows="18"></textarea> </body> </html> [/code] Hope it gets you started.