I want to sort some child divs under a parent div. The child divs has alphanumeric id.
For example: "1_tango" , "5_charlie", "unassigned"
.
For the above example, the sort result should be:
"unassigned" , "1_tango" , "5_charlie",
The code I am using from here:
var mylist = $(this.sub_group_drop_zone);
var listitems = mylist.children('div').get();
listitems.sort(function (a, b) {
var compA = $(a).text().toUpperCase();
var compB = $(b).text().toUpperCase();
return (compA > compB) ? -1 : (compB > compA) ? 1 : 0;
})
$(mylist).append(listitems);
However this results in :
"unassigned", "5_charlie", "1_tango", "3_Beta" ..
How can I fix that. Any idea would be appreciated.