makalet,
а что сортируем ? самим догадаться?
Сортировка блоков по параметрам
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style>
a {
color:#000;
text-decoration:none;
cursor: pointer;
}
a span {
cursor: pointer;
}
a.min span:nth-of-type(1), a span:nth-of-type(2){
display: none;
}
a.min span:nth-of-type(2){
display: inline-block;
}
#sorting{
padding-left: 50px;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript">
</script>
<script type="text/javascript">
$(function () {
var a_sort = $('#sorting a');
var div_conteiner = jQuery.makeArray($('#conteiner div'));
a_sort.each(function (index, self) {
var id = this.id, n = 0;
$(self).click(function (e) {
e.preventDefault();
div_conteiner.sort(function f(a, b) {
a = $(a).data(id);
b = $(b).data(id);
var c = 0
if (a > b) c = 1;
if (a < b) c = -1;
return c
});
n ^= 1;
$(self).toggleClass('min')
if (n) div_conteiner.reverse();
$.map(div_conteiner, function (div) {
$(div).appendTo($('#conteiner'))
});
});
});
});
</script>
</head>
<body>
<div id="sorting">
<a href="#" id="price">цена<span>▲</span><span>▼</span></a>
<a href="#" id="name">название<span>▲</span><span>▼</span></a>
<a href="#" id="rating">рейтинг<span>▲</span><span>▼</span></a>
</div>
<div id="conteiner">
<div data-price="200" data-name="b" data-rating="4">Text 2 price_200 name_b rating_4</div>
<div data-price="100" data-name="c" data-rating="5">Text 1 price_100 name_c rating_5</div>
<div data-price="300" data-name="a" data-rating="3">Text 3 price_300 name_a rating_3</div>
</div>
</body>
</html>