1function sortMeBy(arg, sel, elem, order) {
2 var $selector = $(sel),
3 $element = $selector.children(elem);
4 $element.sort(function(a, b) {
5 var an = parseInt(a.getAttribute(arg)),
6 bn = parseInt(b.getAttribute(arg));
7 if (order == "asc") {
8 if (an > bn)
9 return 1;
10 if (an < bn)
11 return -1;
12 } else if (order == "desc") {
13 if (an < bn)
14 return 1;
15 if (an > bn)
16 return -1;
17 }
18 return 0;
19 });
20 $element.detach().appendTo($selector);
21}
22/* arg : The data-filter to parse for sorting. In our case it would be “data-category”
23sel : This will be the parent selector that contains the data filter. In our case it is the class “search-results”
24elem : This further narrows down the child elements within the parent selector, which is just a “li” in this case
25order : This specifies the sort order. “asc” or “desc” would either be acceptable *\