Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > list in alphabetic order

Reply
Thread Tools

list in alphabetic order

 
 
steve
Guest
Posts: n/a
 
      09-26-2004
I have that list in alphabetic order

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

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.

Thanks


 
Reply With Quote
 
 
 
 
Nico Schuyt
Guest
Posts: n/a
 
      09-26-2004
steve wrote:
> <ul>
> <li>about some text</li>
> <li>be good men</li>
> <li>car doors</li>
> </ul>
> can I maybe use some script to display the list in alphabetic order
> or how can I achieve that.


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
Alternative:
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!
--
Nico
www.nicoschuyt.nl


 
Reply With Quote
 
 
 
 
nice.guy.nige
Guest
Posts: n/a
 
      09-26-2004
While the city slept, steve ((E-Mail Removed)) feverishly typed...

> I have that list in alphabetic order
>
> <ul>
> <li>about some text</li>
> <li>be good men</li>
> <li>car doors</li>
> </ul>
>
> 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.
>
> Thanks


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

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

sort($myList);
reset($myList);
print("<ul>\n");
foreach($myList as $listItem) {
print("<li>$listItem</li>\n");
}
print("</ul>\n");
?>

.... 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,
Nige

--
Nigel Moss
http://www.nigenet.org.uk
Mail address not valid. http://www.velocityreviews.com/forums/(E-Mail Removed), take the DOG. out!
In the land of the blind, the one-eyed man is very, very busy!


 
Reply With Quote
 
steve
Guest
Posts: n/a
 
      09-26-2004
> I have that list in alphabetic order
>
> <ul>
> <li>about some text</li>
> <li>be good men</li>
> <li>car doors</li>
> </ul>
>
> 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.
>
> Thanks



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

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



 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      09-26-2004
steve wrote:

> can I maybe use some script to display the list in alphabetic order
> or how can I achieve that.


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">
<li>football</li>
<li>cricket</li>
<li>snooker</li>
<li>rounders</li>
<li>archery</li>
<li>hockey</li>
</ul>

<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;
myarr.push(t);
}
}
myarr.sort();
j = 0;
for (i = 0; i < ul.childNodes.length; ++i) {
listitem = ul.childNodes[i];
if (listitem.tagName == "LI") {
listitem.innerHTML = myarr[j++];
}
}
</script>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      09-26-2004
"steve" <(E-Mail Removed)> wrote:

> I have that list in alphabetic order

- -
> but the list is getting very big and I straggle to keep it in
> alphabetic order


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, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
Nico Schuyt
Guest
Posts: n/a
 
      09-27-2004
steve wrote:
>> can I maybe use some script to display the list in alphabetic order
>> or how can I achieve that.

> sorry I forgot to mention that there is a links also in the list
> <ul>
> <li><a href="#">about</a> some text</li>
> <li><a href="#">be good men</a></li>
> <li><a href="#">car doors</a></li>
> </ul>


Same tric as I mentioned before. This time create a table in Word with 3
columns:
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.

--
Nico
www.nicoschuyt.nl


 
Reply With Quote
 
steve
Guest
Posts: n/a
 
      09-27-2004
Thanks all of you guys
I will test your suggestions and will see which one will be the most
suitable for me
thanks again


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open & Save dialog box shows files in reverse alphabetic order (Z-A) John Stubbs Computer Support 17 11-25-2009 02:30 PM
I want to list data by alphabetic emre esirik(hacettepe computer science and engineering) C Programming 7 04-09-2008 01:22 AM
Efficient way of generating original alphabetic strings like unix file "split" py_genetic Python 6 06-19-2007 12:23 AM
How to: Windows Quick Tip - How to Force Alphabetic Sorting Silverstrand Reviews & How-To's 3 08-23-2005 08:59 AM
MAJOR problem with alphabetic paging =?Utf-8?B?VGltOjouLg==?= ASP .Net 0 07-26-2005 08:51 AM



Advertisments