carolineschnapp
5/13/2015 - 9:58 PM

Reorder tags inside groups when they contain numbers. Deal with number ranges (that is, a tag that contains two numbers), including price ra

Reorder tags inside groups when they contain numbers. Deal with number ranges (that is, a tag that contains two numbers), including price ranges that use a currency symbol. #Supply

<script>
$('.advanced-filters').each(function() {
  var aNumber = /\d+/;
  var myList = $(this).find('li');
  myList.sort(function (a, b) {
    a = parseInt( aNumber.exec( $(a).text() ), 10 );
    b = parseInt( aNumber.exec( $(b).text() ), 10 );
    if ( isNaN(a)  || isNaN(b) ) {
      return;
    }
    else {
      return a - b;
    }
  });
  $(this).append(myList);
});
</script>

What you want

You would like to re-order this:

... so that it becomes that:

You would also like to re-order this:

... so that it becomes that:

You don't always use numbers in your tags and so you don't want to mess with all those tags that don't contain numbers.

What you need to do

Open your collection-sidebar.liquid snipper in the online template editor, and, at the very bottom of the file, add the code shown below.