# Collection Group By Setting

**URL:** <https://community.glideapps.com/t/collection-group-by-setting/80212>\
**Category:** Ask for Help\
**Created:** [February 21, 2025, 3:31am UTC](https://community.glideapps.com/t/collection-group-by-setting/80212 "2025-02-21T03:31:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![SageCat](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/sagecat/32/85273_2.png) [@SageCat](https://community.glideapps.com/u/SageCat)\
**Post date:** [February 21, 2025, 3:31am UTC](https://community.glideapps.com/t/collection-group-by-setting/80212/1 "2025-02-21T03:31:38Z")

</div>

So I’m using the Collection component and I’ve advised it to group by Status, but is there a way I can change the order that the Status shows? It isn’t in alphabetical order so I’m not sure how it is getting the order, but essentially I want to define the order. Is this possible and, if so, how? Thanks in advance.

EDIT: It is currently showing in this order: Neonate, Adopted, Deceased, Available, Other. But I would rather it show Available, Neonate, Adopted, Deceased, Other.

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [February 21, 2025, 11:06am UTC](https://community.glideapps.com/t/collection-group-by-setting/80212/2 "2025-02-21T11:06:51Z")

</div>

This is due to the sorting option. It sort by the value you settled. Group aren’t sortable out of the box. But here is how to do it.

Create an if then else column with the order you want for each group. Example:  
If status = Available then 1  
If status = Neonate then 2  
If status = Adopted then 3  
If status = Deceased then 4  
If status = Other then 5  
Else 999999

Then, create a template column and set it to “ab”.  
Replace “a” with the if then else column and replace the “b” with the item name column (the one you would use to sort).

Finally, change the sort option to that new Template column.

There you go! Groups and elements are sorted.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [February 22, 2025, 12:50am UTC](https://community.glideapps.com/t/collection-group-by-setting/80212/3 "2025-02-22T00:50:20Z")

</div>

Here’s an alternative with JavaScript, converting all info into a number.

 ![CleanShot 2025-02-22 at 07.48.59](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/b/abd630e46c132f91c69dd6071b827251f97834f7.png)

 ![CleanShot 2025-02-22 at 07.49.11](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/8/f8421cf7ee7fd6c7900af6657cbbe05b1f8d27dc.png)

```auto
const statusOrder = {
    'Available': 1,
    'Neonate': 2,
    'Adopted': 3,
    'Deceased': 4,
    'Other': 5
};

// Convert the first letter of the cat name to its alphabetical position

const letterCode = p2[0].toLowerCase().charCodeAt(0) - 96;

// Combine the status number and letter code using the formula

return statusOrder[p1] * 100 + letterCode;

```

 ![CleanShot 2025-02-22 at 07.50.01](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/8/882147f61913297e0f5bb83bc9c3f0b3336cac6f.png)

 ![CleanShot 2025-02-22 at 07.50.11](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/3/13f3bffe7184402239a9e403704b8eb5afea0a4d.png)

---

<div class="post-metadata">

**Author:** ![SageCat](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/sagecat/32/85273_2.png) [@SageCat](https://community.glideapps.com/u/SageCat)\
**Post date:** [February 22, 2025, 2:08am UTC](https://community.glideapps.com/t/collection-group-by-setting/80212/4 "2025-02-22T02:08:02Z")

</div>

Hi. I understood (I think) the if then else part, but you lost me with the template column paragraph. Are you able to please maybe do a screenshot of the setting so I clearly understand what I’m putting where?

EDIT: I got it! I thought I would paste the example here so others know in future. Thank you so much!

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/2/c2c9702accd9a94d62a061fa8154285afae4c61c.png)

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [February 22, 2025, 2:53am UTC](https://community.glideapps.com/t/collection-group-by-setting/80212/5 "2025-02-22T02:53:09Z")

</div>

My pleasure! Anytime! 😊

---

<div class="post-metadata">

**Author:** ![SageCat](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/sagecat/32/85273_2.png) [@SageCat](https://community.glideapps.com/u/SageCat)\
**Post date:** [March 12, 2025, 2:24am UTC](https://community.glideapps.com/t/collection-group-by-setting/80212/6 "2025-03-12T02:24:04Z")

</div>

Hi, could I please ask one more follow-up question in regards to this? So it is all sorting nicely now into the required status order, thank you very much, but how would I then order the cat names within each status order into alphabetical order? We have just realised that it is in the order that the cats are entered into the database which happened to be alphabetic to start with but subsequently, with use, is no longer so they are listing in the order they happen to have been added.

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [March 12, 2025, 11:46am UTC](https://community.glideapps.com/t/collection-group-by-setting/80212/7 "2025-03-12T11:46:04Z")

</div>

Found the error.

Change the “b” replaced value to the name of the cats.

I did not see your errors in the first place sorry about that!

---

<div class="post-metadata">

**Author:** ![SageCat](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/sagecat/32/85273_2.png) [@SageCat](https://community.glideapps.com/u/SageCat)\
**Post date:** [March 12, 2025, 11:30pm UTC](https://community.glideapps.com/t/collection-group-by-setting/80212/8 "2025-03-12T23:30:00Z")

</div>

Oh that is purrfect! Thank you. Screen shot should anyone be trying similar at home…

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/9/49362579f6564eac5fc5e68df9a6125d647a3de0.png)

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [March 12, 2025, 11:41pm UTC](https://community.glideapps.com/t/collection-group-by-setting/80212/9 "2025-03-12T23:41:30Z")

</div>

Glad it worked!
