[thelist] using array.sort() in JavaScript not handling case correctly

Tom Dell'Aringa pixelmech at yahoo.com
Mon Mar 3 09:13:00 CST 2003


Hello,

I have a select list that I want to dynamically sort by alpha. I am
able to get it to work using array.sort(), except for the fact that
it places upper-case letters BEFORE lower-case letters. My script is
simple enough, I loop through my listbox, pull each text/value array
into a new array, use the sort() function then throw them back in.

There must be some compare function that I need to use but I can't
seem to locate it. The code snippet that handles this is:

================================================================
//make text/value values into arrays for sorting
	textArray = new Array();
	valueArray = new Array();

	for(i=0; i<oSelect.length; i++)
	{
		textArray[i] = oSelect.options[i].text;
		valueArray[i] = oSelect.options[i].value;
	}

	emptySelect(oForm)

    textArray.sort()
    valueArray.sort()
=================================================================

Anyone know how to make it sort the alpha values by alpha no matter
what the case?

TIA

Tom

=====
>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
http://www.pixelmech.com/
var me = tom.pixelmech.webDeveloper();

http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/



More information about the thelist mailing list