$("#show_times_available_" + pos).find("td span").parent().each(function(){
array.push($(this).attr("id"));
array = array.sort();
});
My array takes all the elements and grabs their identifier and pops it into the array, so my array will look like:
[ "mon_0600-0", "sun_0700-0", "thu_0600-0", "thu_0700-0", "tue_0300-0", "wed_0700-0" ];
What I'm trying to do is sort these elements as (mon, tue, wed, etc.) every time a new element is inserted into the array. so my array will end up like:
[ "mon_0600-0", "tue_0300-0", "wed_0700-0", "thu_0600-0", "thu_0700-0", "sun_0700-0" ];
Using the base function sort()will be placed in alphabetical order, and I know that a function sort()can take another function. I'm just not sure how to set this in javascript javascript or jQuery. Is there a way to CASE THEN or use when()and then()to order them? I am looking for everything around google and SO, but nothing.