<ul id="sortme">

{% if settings.sort-dropdown-a-check %}                        
  <li class="clearfix filter">
{% assign tags = settings.sort_by_color  | replace: ' ,', ',' | replace: ', ', ',' | split: ',' %}    
<p>Shop by color</p>
    <select class="coll-filter">
      <option value="">All</option>
      {% for tag in tags %}
      {% if current_tags contains tag %}
      <option value="{{ tag | handle }}" selected>{{ tag }}</option>
      {% elsif collection.all_tags contains tag %}
      <option value="{{ tag | handle }}">{{ tag }}</option>
      {% endif %}
      {% endfor %}
    </select>
  </li>
{% endif %}

{% if settings.sort-dropdown-b-check %}
  <li class="clearfix filter">
{% assign tags = settings.sort_by_size  | replace: ' ,', ',' | replace: ', ', ',' | split: ',' %}    
<p>Shop by Size</p>
    <select class="coll-filter">
      <option value="">All</option>
      {% for tag in tags %}
      {% if current_tags contains tag %}
      <option value="{{ tag | handle }}" selected>{{ tag }}</option>
      {% elsif collection.all_tags contains tag %}
      <option value="{{ tag | handle }}">{{ tag }}</option>
      {% endif %}
      {% endfor %}
    </select>
  </li>
{% endif %}

{% if settings.sort-dropdown-c-check %}
  <li class="clearfix filter">
{% assign tags = settings.sort_by_anything_else  | replace: ' ,', ',' | replace: ', ', ',' | split: ',' %}    
<p>Shop by {{ settings.sort_by_anything_else_label }}</p>
    <select class="coll-filter">
      <option value="">All</option>
      {% for tag in tags %}
      {% if current_tags contains tag %}
      <option value="{{ tag | handle }}" selected>{{ tag }}</option>
      {% elsif collection.all_tags contains tag %}
      <option value="{{ tag | handle }}">{{ tag }}</option>
      {% endif %}
      {% endfor %}
    </select>
  </li>
{% endif %}

</ul>  
                   
     
<script>
  /* Product Tag Filters - Good for any number of filters on any type of collection pages */
  /* Give you product tag filter select element a class of coll-filter */
  /* Give your collection select a class of coll-picker */
  /* Brought to you by Caroline Schnapp */
  var allFilters = jQuery('.coll-filter, .coll-picker');
  allFilters.change(function() {
    var newTags = [];
    jQuery('.coll-filter').each(function() { 
      if (jQuery(this).val()) {
        newTags.push(jQuery(this).val());
      }
    });
    if (newTags.length) {
      var query = newTags.join('+');
      if (jQuery('.coll-picker').length) {
        window.location.href = '/collections/' + jQuery('.coll-picker').val() + '/' + query;
      }
      else {
        window.location.href = jQuery('{{ 'tag' | link_to_tag: 'tag' }}').attr('href').replace('tag', query);
      }
    } 
    else {
      if (jQuery('.coll-picker').length) {
        window.location.href = '/collections/' + jQuery('.coll-picker').val();
      }
      else {
        {% if collection.handle %}
        window.location.href = '/collections/{{ collection.handle }}';
        {% elsif collection.products.first.type == collection.title %}
        window.location.href = '{{ collection.title | url_for_type }}';
        {% elsif collection.products.first.vendor == collection.title %}
        window.location.href = '{{ collection.title | url_for_vendor }}';
        {% endif %}
      }
    }
  });
   $(".coll-filter").chosen({ disable_search_threshold: 20 });
  $(".selectBox").chosen({ disable_search_threshold: 20 });
</script>