Hey guys,

I've got this neat script that will take the LI list entries from a UL of a specified class and alphabetize the LI's...

However, if you have a list like this:

-Apple Fruit
-(Tomato) Vegetable
-Orange Fruit

it would sort it like this:

-(Tomato) Vegetable
-Apple Fruit
-Orange Fruit

Because of the parenthesis, which is sees as having greater value than A, or O in the alphabet.

Just wondering if anyone could look at the code below and get me setup with an array or something that has exclusions of characters like the parenthesis above.

Thanks guys!

function getText(hoo) {
var A= [], next, T, pa, i;
if (!hoo) return A;
if (hoo.nodeType== 3 && /\w+/.test(hoo.data)) A.push(hoo);
else if (hoo.hasChildNodes()){
pa= hoo.childNodes, i= 0;
while (pa[i]){
next= pa[i++];
T= next.nodeType;
if (T== 3) {
if (/\w+/.test(next.data)) A.push(next);
}
else if (T== 1) A=A.concat(arguments.callee(next));
}
}
return A;
}

function listSort(){
var U= document.getElementsByTagName('ul');
var L= U.length,tem,A;
while(L--){
U2= U[L];
if(U2.className== "cls_top_results"){
A= getText(U2);
A.sort(function(a,b){
a= a.data.toLowerCase().replace(/^ */g,'');
b= b.data.toLowerCase().replace(/^ */g,'');
if(a== b)return 0;
return a > b? 1 : -1;
})
}
while(A.length){
hoo= A.pop();
while(hoo && hoo.nodeName!= 'LI') hoo=hoo.parentNode;
if(hoo) U2.insertBefore(hoo,U2.firstChild);
}
}
}