# Stacking multiple CMS Sort fields on combined collection

**URL:** <https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773>\
**Category:** Attributes\
**Created:** [August 11, 2023, 5:00pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773 "2023-08-11T17:00:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Poetic](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/poetic/32/3018_2.png) [@Poetic](https://forum.finsweet.com/u/Poetic)\
**Post date:** [August 11, 2023, 5:00pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/1 "2023-08-11T17:00:52Z")

</div>

**Context:**  
I have a client with many different resource types (blogs, news, case studies, etc.). Each resource type is a collection, but they want to have one information hub with all resource combined and filterable. I have the following attributes set up on the page: CMS Combine, CMS Nest, CMS Filter, CMS Load, CMS Sort. The client want the resources sorted by date(newest-oldest), and they want to select ~3 featured resources “pinned” (sorted) to show at the top of the list.

**Issue:**  
I’m having trouble stacking the sorts, would the “feature” sort field be able to be added to the same trigger button if it is sorting the same combined collection list?

My current setup (not working) is to have a second trigger button, with fs-cmssort-element = “trigger-2” and the combined collection list has the attribute fs-cmssort-element = list, list-2?

Any insight on how to get this working?

I found this on the sort documentation but I’m still a bit confused: “If more than one trigger belongs to the same list (currently only supported with Button Triggers), all the triggers must match the list instance number.”

Read-Only Link:  
[https://preview.webflow.com/preview/insidetrack?utm\_medium=preview\_link&utm\_source=designer&utm\_content=insidetrack&preview=62e29e4f093b1097bf3346c9d4065c4a&pageId=64d664f168e7ae977aa60308&workflow=preview](https://preview.webflow.com/preview/insidetrack?utm_medium=preview_link&utm_source=designer&utm_content=insidetrack&preview=62e29e4f093b1097bf3346c9d4065c4a&pageId=64d664f168e7ae977aa60308&workflow=preview)

 ![Screenshot 2023-08-11 at 9.51.00 AM](https://europe1.discourse-cdn.com/flex013/uploads/finsweet1/original/2X/3/318651652aacf94f84e5c8df241f056910b8bb1d.png)

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [August 11, 2023, 6:28pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/2 "2023-08-11T18:28:50Z")

</div>

hey @Poetic! the `-x` suffixes are used when we have more than one list to be sorted/filtered/loaded. If you only have one list all your elements should not have any suffixes as they belong to the same `fs-cmssort-element = list`.

For multiple sort triggers, what will differentiate them is the `IDENTIFIER` you use to link the fields to be sorted. Let me know if this makes sense 🙂

---

<div class="post-metadata">

**Author:** ![Poetic](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/poetic/32/3018_2.png) [@Poetic](https://forum.finsweet.com/u/Poetic)\
**Post date:** [August 14, 2023, 3:13pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/3 "2023-08-14T15:13:33Z")

</div>

This makes sense, I adjusted my setup accordingly. However, even though this is set up correctly according to automated support, neither sort is working. Any ideas on how to get this functional?

[https://insidetrack.webflow.io/resource-hub?fs-attributes-support=true](https://insidetrack.webflow.io/resource-hub?fs-attributes-support=true)

---

<div class="post-metadata">

**Author:** ![Poetic](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/poetic/32/3018_2.png) [@Poetic](https://forum.finsweet.com/u/Poetic)\
**Post date:** [August 14, 2023, 3:35pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/4 "2023-08-14T15:35:19Z")

</div>

@Support-Luis

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [August 14, 2023, 6:02pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/5 "2023-08-14T18:02:13Z")

</div>

Hey @Poetic! I see you are using `fs-cmssort-field="IDENTIFIER"` on your date fields. I do suggest you use another identifier such as `date` or `published`.

Also, when combining CMS Nest and CMS Combine you’ll need to prevent the script from running instantly, you can do this by using this script for CMS Combine

```auto
    <script
      defer
      fs-attributes-preventload="true"
      src="https://cdn.jsdelivr.net/npm/@finsweet/attributes-cmscombine@1/cmscombine.js"
    ></script>

```

And then using this callback to initialize and click the button after both scripts have done loading

```auto
<script>
      window.fsAttributes = window.fsAttributes || [];
      window.fsAttributes.push([
        'cmsnest',
        (listInstances) => {
          console.log('cmsnest Successfully loaded!');

          const [listInstance] = listInstances;

          window.fsAttributes.cmscombine.init();

          window.fsAttributes.push([
            'cmscombine',
            (listInstances) => {
              document.querySelector('.fs_cmssort_button-').click();
            },
          ]);
        },
      ]);
    </script>

```

You are also missing the `fs-cmssort-type = date` on your trigger button.

For the featured field we will need to think of another way as all items have the same content in the `Featured` element inside the blog card and the sorting does not affect them. Can you add the featured field as an embed like on the image attached? Once you have the date sort working correctly we can jump on this other field

 ![Screen Shot 2023-08-14 at 12.00.50](https://europe1.discourse-cdn.com/flex013/uploads/finsweet1/original/2X/d/d79190829e469e0928c59438b341c58d2efbeebd.png)

---

<div class="post-metadata">

**Author:** ![Poetic](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/poetic/32/3018_2.png) [@Poetic](https://forum.finsweet.com/u/Poetic)\
**Post date:** [August 14, 2023, 8:29pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/6 "2023-08-14T20:29:54Z")

</div>

@Support-Luis

Thanks for the help! I’ve made the following changes to the build:

- added the code snippets

- updated the identifier for the date sort to fs-cmssort-field = “published”

- added fs-cmssort-type = date to the trigger button

- Added an embed to each resource collection in the conditionally visible div block as you described above.

Next Steps:

1. The date sort is still not functioning properly, even after the changes above
2. Would the featured element embed be the element with the “featured”  
 ![Screenshot 2023-08-14 at 1.21.37 PM](https://europe1.discourse-cdn.com/flex013/uploads/finsweet1/original/2X/9/9b43673b0ff1e61fc674875fdcf15583b05b8394.png)  
 ![Screenshot 2023-08-14 at 1.29.20 PM](https://europe1.discourse-cdn.com/flex013/uploads/finsweet1/original/2X/e/e5e94d4f00b98a3ec30f7285cc63cab4ea4bdb15.png)  
sort attribute?

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [August 14, 2023, 9:08pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/7 "2023-08-14T21:08:59Z")

</div>

Can you share your link? [https://insidetrack.webflow.io/resource-hub](https://insidetrack.webflow.io/resource-hub) goes to a 404

---

<div class="post-metadata">

**Author:** ![Poetic](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/poetic/32/3018_2.png) [@Poetic](https://forum.finsweet.com/u/Poetic)\
**Post date:** [August 14, 2023, 9:14pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/8 "2023-08-14T21:14:28Z")

</div>

@Support-Luis  
[https://preview.webflow.com/preview/insidetrack?utm\_medium=preview\_link&utm\_source=designer&utm\_content=insidetrack&preview=62e29e4f093b1097bf3346c9d4065c4a&pageId=64d664f168e7ae977aa60308&workflow=preview](https://preview.webflow.com/preview/insidetrack?utm_medium=preview_link&utm_source=designer&utm_content=insidetrack&preview=62e29e4f093b1097bf3346c9d4065c4a&pageId=64d664f168e7ae977aa60308&workflow=preview)

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [August 14, 2023, 9:56pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/9 "2023-08-14T21:56:28Z")

</div>

@Poetic I am afraid we will not be able to use the same button to trigger both sort fields. Nor a combination of two sorting fields. So a compromise on which field should the list be sorted by must be made. If you go with the `date` field, removing the `featured` identifier from the trigger will do the trick.

If you go with the `featured` field you’ll need to remove the `date` from the trigger and move your `fs-cmssort-field = featured` to only the HTML embed.

I also see that you have the CMS Sort script added twice, one without the prevented load and one with the setting applied. I also made a typo on the class name for the sort button it should be `.fs_cmssort_button` my bad.

---

<div class="post-metadata">

**Author:** ![Poetic](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/poetic/32/3018_2.png) [@Poetic](https://forum.finsweet.com/u/Poetic)\
**Post date:** [August 14, 2023, 11:01pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/10 "2023-08-14T23:01:51Z")

</div>

@Support-Luis Thanks for the explanation my last few questions are:

1. To clarify, are you saying that CMS sort can only apply 1 sort per list? And we can’t add an additional trigger button to sort by both fields?

2. Can you show where you see the CMS sort script added twice? Do you mean the CMS sort or CMS combine script?

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [August 14, 2023, 11:08pm UTC](https://forum.finsweet.com/t/stacking-multiple-cms-sort-fields-on-combined-collection/1773/11 "2023-08-14T23:08:43Z")

</div>

1. CMS Sort can have several sort fields per list but there is no current what of sorting by two fields at the same time. The list will be filters by “featured” or by “date” but it does not stack the sorts as “Sort by featured then by date”

2. The duplicated script is in your page settings, you can remove the top one as it is missing the `fs-attributes-preventload = "true"` setting

 ![Screen Shot 2023-08-14 at 17.07.24](https://europe1.discourse-cdn.com/flex013/uploads/finsweet1/original/2X/d/dcc317737bfd6cd7cceea79a1d48712c0e0b5e99.jpeg)  
e
