Discussion:
Alphabetical order in Dreamweaver
(too old to reply)
cocoalex
2006-01-30 17:25:49 UTC
Permalink
I have a very big list.

The list items are like this:

<li class="text"><a href="link.php">Some text here</a>
<li class="text"><a href="link3.php">Some other text</a>
<li class="text"><a href="link2.php">And some other text</a>

Can I order this list alphabetically in Dreamweaver? Or another program?

Thanks!
m***@gmail.com
2006-01-30 18:01:28 UTC
Permalink
if you have microsoft excel, you could copy the list into there. In
excel i think you select the cells you want to make alphabetcal and
then in one of the menus you can click sort>alphabetical order or
somthing.

Hope this helps
bregent
2006-01-30 18:55:39 UTC
Permalink
A 'very big list' plus 'sorting' = database. It will make your life easier.
cocoalex
2006-01-30 21:20:49 UTC
Permalink
Originally posted by: bregent
A 'very big list' plus 'sorting' = database. It will make your life easier.

Yes, I know. But I already created my webpages in html format. Plus, I don't
know MySQL & PHP and I don't the money to pay somebody else to do it.

SO ... html it is.
Joe Makowiec
2006-01-30 21:33:42 UTC
Permalink
Post by cocoalex
Post by cocoalex
Originally posted by: bregent
A 'very big list' plus 'sorting' = database. It will make your life easier.
Yes, I know. But I already created my webpages in html format. Plus, I don't
know MySQL & PHP and I don't the money to pay somebody else to do it.
SO ... html it is.
How big is it? And how often will it change? Because if it's fairly
big, and it changes often, it will be cheaper long-run to do it right
(ie a database) in the first place.

If you figure you really, really have to do it, use a spreadsheet. You
said your code looks like this:

<li class="text"><a href="link.php">Some text here</a>
<li class="text"><a href="link3.php">Some other text</a>
<li class="text"><a href="link2.php">And some other text</a>

- Drop your whole list into your spreadsheet (Excel?) It should wind
up being in one column.
- Create a second column. If the links are going to be variable
length, the formula in B1 will be =find("php",A1) Assuming none of the
links have anything after the href, this will work.
- Create a third column. =mid(A1,B1+5,30) This will give you the
first 30 characters text string. (Lengthen if that won't be enough).
- Sort on column C
- Delete Columns B + C
- Save as a text file
- Re-insert into DW
--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
cocoalex
2006-01-30 22:30:59 UTC
Permalink
The links are not all like that.

link.php

They totally different:
"http://www.some text ........ .asp"
"http://www.some text ........ .htm"
"http://www.some text ........ .html"
"http://www.some text ........ .jpg"
"http://www.some text ........ .gif"

and so on ...
Joe Makowiec
2006-01-30 23:08:22 UTC
Permalink
Post by cocoalex
The links are not all like that.
link.php
"http://www.some text ........ .asp"
"http://www.some text ........ .htm"
"http://www.some text ........ .html"
"http://www.some text ........ .jpg"
"http://www.some text ........ .gif"
http://www.lib.utexas.edu/maps/map_sites/cities_sites.html
That's ugly.

If you can be sure that everything you use will be in this form:

<li><a href="whatever">Text goes here</a></li>

you can follow the method from my previous post in Excel like this:

ColumnA
Full link

ColumnB
=find(">",a1,12)

ColumnC
=mid(a1,b1+1,30)

The find in column B starts after the <li> tag and finds the ">"
character. It's the text after that which you want to sort on.
--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Mick White
2006-01-30 23:51:00 UTC
Permalink
Post by cocoalex
The links are not all like that.
link.php
"http://www.some text ........ .asp"
"http://www.some text ........ .htm"
"http://www.some text ........ .html"
"http://www.some text ........ .jpg"
"http://www.some text ........ .gif"
and so on ...
You mean sort "by URL"? You said "by text" before.
Sorting by URL would have been a lot easier...
Mick

Mick White
2006-01-30 19:04:22 UTC
Permalink
Post by cocoalex
I have a very big list.
<li class="text"><a href="link.php">Some text here</a>
<li class="text"><a href="link3.php">Some other text</a>
<li class="text"><a href="link2.php">And some other text</a>
Can I order this list alphabetically in Dreamweaver? Or another program?
Thanks!
Yes, order by href, or by text, or by what?
Mick
cocoalex
2006-01-30 21:18:20 UTC
Permalink
Originally posted by: Newsgroup User
Yes, order by href, or by text, or by what?
Mick


By text.
Mick White
2006-01-30 23:20:16 UTC
Permalink
Post by Mick White
Yes, order by href, or by text, or by what?
Mick
By text.
<body>
<script type="text/javascript">
cloned=false;
function sortList(){
if(!cloned){
var ARR=[];
var L=document.getElementById("linx");
var list=L.getElementsByTagName("LI")
for(var i=0;i<list.length;i++){
ARR[i]=list[i].cloneNode(true)
}
ARR.sort(sortText)
for(var j=0;j<ARR.length;j++){
document.getElementById("molinx").appendChild(ARR[j]);
}
L.style.display="none" ;
cloned=true;
}
}
function sortText(a,b){
x=a.firstChild.firstChild.data;
y= b.firstChild.firstChild.data
return x>y?1:x<y?-1:0;
}

</script>
<ul id="linx">
<li class="text"><a href="link.php">Some text here</a>
<li class="text"><a href="link3.php">Some other text</a>
<li class="text"><a href="link2.php">And some other text</a>
<li class="text"><a href="link.php">ZZ Top</a>
<li class="text"><a href="link3.php">Aardvarks</a>
<li class="text"><a href="link2.php">Llamas</a>

</ul>
<ul id="molinx"></ul>
<input name="" type="button" value="Sort List" onclick="sortList()">
</body>

Mick
cocoalex
2006-01-30 22:32:08 UTC
Permalink
My list is similar with this:

http://www.lib.utexas.edu/maps/map_sites/cities_sites.html
Continue reading on narkive:
Loading...