list in alphabetic order

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have that list in alphabetic order

<li>about some text</li>
<li>be good  men</li>
<li>car doors</li>

but the list is getting very big and I straggle to keep it in
alphabetic order
can I maybe use some script to display  the list in alphabetic order
or how can I achieve that.


Re: list in alphabetic order

steve wrote:
Quoted text here. Click to load it

If you have some knowledge of PHP and MySQL: Fill a MySQL-table with all the
items and create the list based on a query.
But, that means a lot of work :-)
    Maintain the list-items as plain text in MS-Word.
    Use Word to sort the lines
    Copy and paste in a HTML-editor (like FrontPage) and change it there
into a list
Easy and can be done in a few seconds.

Good luck!

Re: list in alphabetic order

While the city slept, steve (nospam@nospam.non) feverishly typed...

Quoted text here. Click to load it

You can put the list items in an array, sort the array, then step through
the array to display them. In PHP;

$myList = array("about some text",
                         "be good men",
                         "this is not in alpha order",
                         "car doors",
                         "aardvarks look silly");

foreach($myList as $listItem) {

... then add to the end of the array as and when you have a new item.

Alternatively, you can store the items in a MySQL database table (eg, called
"myItems") then when you get them, specify "sort asc" in the sql statement.

This is straight off the top of my head, not tested, but should at least
point you in the right direction.

Hope that helps,

Nigel Moss
Mail address not valid., take the DOG. out!
In the land of the blind, the one-eyed man is very, very busy!

Re: list in alphabetic order

Quoted text here. Click to load it

sorry I forgot to mention that there is a links also in the list

<li><a href="#">about</a> some text</li>
<li><a href="#">be good  men</a></li>
<li><a href="#">car doors</a></li>

Re: list in alphabetic order

steve wrote:
Quoted text here. Click to load it

Same tric as I mentioned before. This time create a table in Word with 3
    a.    ><a href="xxx.htm">
    b.    Link description
    c.    >
Sort alfabetically on the second column, paste as plain paragraphs into a
HTML editor and convert to a list.


Re: list in alphabetic order

steve wrote:

Quoted text here. Click to load it

Others have shown how this can be done using server-side scripts. Here's a
client-side way. Note this uses the non-standard (but widely supported)
DOM extension "innerHTML". With a little massaging it could probably be
done in a more standards-compliant way, but it would probably be not as
widely supported.

<ul id="sortme">

<script type="text/javascript">
  var i, j;     // counters
  var myarr;    // array for sorting things
  var listitem; // temporary reference to make things easier to read
  var ul;       // list to operate on
  ul = document.getElementById("sortme");
  myarr = new Array();
  for (i = 0; i < ul.childNodes.length; ++i) {
    listitem = ul.childNodes[i];
    if (listitem.tagName == "LI") {
      var t = listitem.innerHTML;
  j = 0;
  for (i = 0; i < ul.childNodes.length; ++i) {
    listitem = ul.childNodes[i];
    if (listitem.tagName == "LI") {
      listitem.innerHTML = myarr[j++];

Toby A Inkster BSc (Hons) ARCS
Contact Me  ~

Re: list in alphabetic order

Quoted text here. Click to load it
- -
Quoted text here. Click to load it

Then find a tool that sorts them for you, and use its output as content
of your HTML document. There are lots of such utilities. But beware:
_correctly_ ordering strings is one of the most difficult task in
computing, and naturally requires a useful but exact definition of
"correct order". National standards on ordering may involve rules that
are not implementable algorithmically or _very_ hard to implement.

So what I suggest is: use a suitable tool to get most of the ordering
done automatically, and check and fix the difficult items "by hand".

Yucca, /
Pages about Web authoring:

Re: list in alphabetic order

Thanks all of you guys
I will test your suggestions and will see which one will be the most
suitable for me
thanks again

Site Timeline