Hi Michael, Thanks for replying.
The sort won't need to be done very often at all so I imagine that your solution would be ideal. Having a bit of trouble getting it to work though: $("#group_add").livequery('submit',function() { var group_name = $(this).children("#group_title").val(); var myvar = 'hello'; var group_array = []; if(group_name != '') { $("#group_list").children("li").each(function() { group_array[] = this.text(); }); group_array[] = group_name; group_array.sort(); alert(group_array); } return false; }); It seems like the function called by each() can't access the group_array[] array. How do I change the scope of group_array to allow me to add elements to it within my each() function? Or is there a better way of going about it? Sam On Feb 10, 8:51 pm, Michael Lawson <mjlaw...@us.ibm.com> wrote: > How often are you going to be doing this sort? > > You could just say that when you add something to the list, pull them all > out and put them into an array, sort the array and then put it back out > cheers > > Michael Lawson > Content Tools Developer, Global Solutions, ibm.com > Phone: 1-919-517-1568 Tieline: 255-1568 > E-mail: mjlaw...@us.ibm.com > > 'Examine my teachings critically, as a gold assayer would test gold. If you > find they make sense, conform to your experience, and don't harm yourself > or others, only then should you accept them.' > > From: Sam Hastings <sam.hasti...@gmail.com> > > > To: "jQuery (English)" <jquery-en@googlegroups.com> > > > Date: 02/10/2009 03:50 PM > > > Subject: [jQuery] Adding an LI element to an OL > > > Hi everyone, > > I've got an ordered list (OL) containing several LI items, currently > arranged in alphabetical order. > > How hard would it be to create a new LI element, and put it in the > right alphabetical position based on its value? > > Sam > > graycol.gif > < 1KViewDownload > > ecblank.gif > < 1KViewDownload