<p>I ran into the same problems as you and I believe I've solved it, but it may be different for your specific use case.</p>

<ol>
<li><p>There may be a way to control this with the <code>init</code> options but I wasn't able to find a way to do it, so I just edited the <code>searchplus.js</code> code directly in the <code>searchplus</code> folder. Look for something like <code>e.getFacetValues(i,{sortBy:["isRefined:desc","count:desc"]})</code> and change it to <code>e.getFacetValues(i,{sortBy:["name:asc"]})</code> instead (you can leave the <code>isRefined:desc</code> part at the front as well if you would like the filtered options to automatically populate to the top of the list). Keep in mind that changing the <code>js</code> file is a global change which would affect other faceted forms if you have more than one on your site.</p></li>
<li><p>When you define the facets in your <code>init</code> code: <code>$(this).searchplus({facets: ['facet1', 'facet2'],});</code>, replace <code>facets</code> with <code>disjunctiveFacets</code> and you should stop seeing filters disappear from the facet you're selecting (see faceting options on <a href="http://squarebit.co.uk/software/craft/searchplus/usage/javascript-setup/helper-reference#facet-parameters" rel="nofollow noreferrer">the Search Plus docs</a>. The other facet's filters <em>will</em> disappear though depending on if there are valid matches or not, but it will at least prevent the other filters from your <em>selected</em> facet from disappearing immediately.</p></li>
</ol>

CC BY-SA 3.0
2017-07-18T19:57:18.783Z
2017-07-18T19:57:18.783Z
Tyler DeBoer
<p>I'm using the Search Plus plugin with Craft, it's been a great help! 
I have 2 questions I need help with, as the Search Plus docs are not too clear so far:</p>

<ol>
<li>I have a search page with filters (facets) in place, however these
facets are arranged according to search count by default. I want to
sort them by alphabetical order instead, and I've seen that it is
possible with Algolia, but I need help to do that with Search Plus.</li>
<li>Upon clicking on a filter checkbox, the other filters disappear. How
do I trigger them to still appear but with a different CSS class
applied?</li>
</ol>

<plugin-searchplus>
Search Plus Plugin: How to sort facets?
# Search Plus Plugin: How to sort facets?

(Asked by: username_0 on 2017-06-01)

I'm using the Search Plus plugin with Craft, it's been a great help!
I have 2 questions I need help with, as the Search Plus docs are not too clear so far:

1. I have a search page with filters (facets) in place, however these
   facets are arranged according to search count by default. I want to
   sort them by alphabetical order instead, and I've seen that it is
   possible with Algolia, but I need help to do that with Search Plus.
2. Upon clicking on a filter checkbox, the other filters disappear. How
   do I trigger them to still appear but with a different CSS class
   applied?

**Tags:** plugin-searchplus


---

## 1 answers

### Answer by username_1 on 2017-07-18. Score: 1 | Accepted answer

I ran into the same problems as you and I believe I've solved it, but it may be different for your specific use case.

1. There may be a way to control this with the `init` options but I wasn't able to find a way to do it, so I just edited the `searchplus.js` code directly in the `searchplus` folder. Look for something like `e.getFacetValues(i,{sortBy:["isRefined:desc","count:desc"]})` and change it to `e.getFacetValues(i,{sortBy:["name:asc"]})` instead (you can leave the `isRefined:desc` part at the front as well if you would like the filtered options to automatically populate to the top of the list). Keep in mind that changing the `js` file is a global change which would affect other faceted forms if you have more than one on your site.
2. When you define the facets in your `init` code: `$(this).searchplus({facets: ['facet1', 'facet2'],});`, replace `facets` with `disjunctiveFacets` and you should stop seeing filters disappear from the facet you're selecting (see faceting options on [the Search Plus docs](http://squarebit.co.uk/software/craft/searchplus/usage/javascript-setup/helper-reference#facet-parameters). The other facet's filters *will* disappear though depending on if there are valid matches or not, but it will at least prevent the other filters from your *selected* facet from disappearing immediately.


---

