There is a range input from which I get the value using jquery:

<input class="add" type="range" name="slider-1" id="slider-1" min="0" max="10" value="5" /> 

and a bunch of divs:

  <div class="blocks block-1" id="5">Div 1</div> <div class="blocks block-1" id="3">Div 2</div> <div class="blocks block-1" id="1">Div 3</div> <div class="blocks block-1" id="8">Div 4</div> <div class="blocks block-1" id="2">Div 5</div> 

How to sort divas by value c range input?

    1 answer 1

    actually everything is simple

     var sortedArray = $("div[class^='wrap_']").get().sort(function(a, b) { var idx = parseInt($(a).find(".sort_by").val(),10); var idx2 = parseInt($(b).find(".sort_by").val(),10); return idx > idx2; }); $(sortedArray).appendTo("body");