Вариант ...
<!DOCTYPE HTML>
<html>
<head>
<title></title>
</head>
<body>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<div class=WRP>
<div id=d>id=d</div>
<div id=b>id=b</div>
<div id=c>id=c</div>
<div id=a>id=a</div>
</div>
<script>
var divs =$('.WRP div');
var arr = jQuery.makeArray(divs).sort(function f(a,b)
{
var c = 0
if (a.id > b.id ) c = 1;
if (a.id < b.id ) c = -1;
return c
});
$(arr).appendTo('.WRP')
</script>
</body>
</html>