Implementation of js, jQuery sorting:
Key points: To achieve sorting, the simplest way is to
first read the tags into the object array with jQuery
Use js to sort the object array (sort the object array, Do not try to make direct changes to the content of the web page)
Overwrite the tag array on the web page with the object array content;
//Sort from short text to long
//Sort from short text to long text
var arr_a=new Array();
var i=0;
$(".type_list_txt > span:contains('T-shirt')").parent().children("a").each(function(){
arr_a[i ]=$(this).clone();
i ;
});
for(i=0; i
{
for(j= i 1;j{
if($(arr_a[i]).text().length > $(arr_a[j]).text().length )
{
temp=arr_a[i];
arr_a[i]=arr_a[j];
arr_a[j]=temp;
}
}
}
i=0;
$(".type_list_txt > span:contains('T-shirt')").parent().children("a").each(function(){
$(this ).replaceWith($(arr_a[i]));
i ;
});