mortido,
чуть короче но тоже самое.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(window).load(function () {
var c = jQuery.makeArray($(".deck_container div"));
c.sort(function (a, b) {
a = $(a).attr("card_cost");
b = $(b).attr("card_cost");
return b - a
});
$(c).appendTo(".deck_container")
});
</script>
</head>
<body>
<div class='deck_container'>
<div card_cost="20">20</div>
<div card_cost="8">8</div>
<div card_cost="1">1</div>
<div card_cost="5">5</div>
<div card_cost="17">17</div>
</div>
</body>
</html>