Finally i got my answer.
$('#swappable > span').sort(function (a, b) {
var ar = a.getAttribute("row");
var ac = a.getAttribute("col");
var br = b.getAttribute("row");
var bc = b.getAttribute("col");
if(ar > br)
{
return ar > br;
}
if(ar === br)
{
if(ac > bc)
{
return ac > bc;
}
}
}).appendTo('#swappable');
Please check below Fiddle