PDA

View Full Version : Alphabetize by paragraph


Walt (Anchorage)
01-14-2010, 05:04 PM
I'm using Dreamweaver MX in Vista (which has it's own problems). I have a page with a large number of paragraphs that I would like to have put in alphabetical order when I add new paragraphs. The text is not in a table format so sort doesn't work. I tried to copy them to Word, alphabetize them then paste them back but I loose all the links and pop ups.

There has got to be a simple way to do this. What am I missing? Thanks for any help you can offer.

DWcourse
01-14-2010, 05:56 PM
not simple butů

You could do a search and replace in the code to change <p> to <tr><td> and </p> to </td></tr> and then add <table> before and </table> after ALL the paragraphs. That would put them in a table and allow you to use the sort function.

Of course I'd recommend making a backup before you try it.

d a v e
01-14-2010, 07:05 PM
can't you add new paragraphs in order at the time of, er , adding??

DWcourse
01-14-2010, 07:15 PM
can't you add new paragraphs in order at the time of, er , adding??

And what fun would that be?;-)

Walt (Anchorage)
01-14-2010, 11:46 PM
I replaced the codeing and put the text it into a table. Now I can sort the text. It works but I would think there should be an easier way to alphabetize. Now I only have 25 more pages to change into tables.

The reason I don't want to put each paragraph in order as I add them is that I often copy in a large number at a time and it's very time consuming to stop and put each one in alphabetical order. Changing the codeing will take some time but I'll wait till I have a lot of new data then add it to the table.

I suspect there is a PHP program that would alphabetize the info for me but I don't have time to learn a new language.

Corrosive
01-15-2010, 06:10 AM
Actually I don't think the PHP for this would be that hard. You'd put your paragraphs into a sql table and then, when the visitor opens the page it will call the paras from the database and you can sort the resulting array in a with about three lines of code. From the PHP Manual;

<?php

$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "\n";
}

?>

I'd probably split the pages alphabetically a,b,c,d etc. each on a page and I'd split the tables in the sql database in the same way but I don't think it would be all that hard.