# Repeating group sorting!

**URL:** <https://forum.bubble.io/t/repeating-group-sorting/207087>\
**Category:** Need help\
**Created:** [May 17, 2022, 7:30pm UTC](https://forum.bubble.io/t/repeating-group-sorting/207087 "2022-05-17T19:30:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![triplog](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@triplog](https://forum.bubble.io/u/triplog)\
**Post date:** [May 17, 2022, 7:30pm UTC](https://forum.bubble.io/t/repeating-group-sorting/207087/1 "2022-05-17T19:30:54Z")

</div>

Hello,

I got around the same question as this one:

> [@Custom / advanced RG sorting](http://forum.bubble.io/t/custom-advanced-rg-sorting/111489):
>
> Hi bubblers, Looking for some advice for custom sorting a repeating group. I have a list of Products. Each Product has a Brand. I want to sort the Products RG so that it shows the first product of each Brand, then 2nd product of each Brand and so on. So the RG will be sorted along the lines of: 1st Product of Brand 1 1st Product of Brand 2 1st Product of Brand 3 2nd Product of Brand 1 2nd Product of Brand 2 2nd Product of Brand 3 etc. Not sure if this is possible natively or whether a plu…

I need to be able to sort on a specific value that can not run trough eachother.(repeating group)  
What i don’t want:  
product 1  
product 2  
product 3  
product 2

But i need:  
product 1  
product 1  
product 3  
product 3  
product 3  
product 2  
product 2  
product 2

As long as they are always seperated. Its good.  
This should not be so difficult i would assume but cant seem to figure it out.

Any help or pointing me in the right direction is very much appreciated.  
Thanks in advance.,

---

<div class="post-metadata">

**Author:** ![bubble.trouble](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@bubble.trouble](https://forum.bubble.io/u/bubble.trouble)\
**Post date:** [May 17, 2022, 8:03pm UTC](https://forum.bubble.io/t/repeating-group-sorting/207087/2 "2022-05-17T20:03:13Z")

</div>

Hello,

One way to achieve this result is to use two repeating groups. This can be inefficient with large datasets, but if I understand your question properly, it will provide a solution.

The first repeating group is used as the outer grouping, the inner repeating group is used to display the data. In the first repeating group, you will want to use a group by on your data source and then sort by the column you are wishing to have your list sorted by (i.e. Brand if you are trying to achieve Brand → Product). The second (inner) repeating group needs to have a constraint that restricts it to only the values that match the first repeating group. After that you can sort by Product (or any other column you choose. See below:

![Screenshot 2022-05-17 at 4.00.44 PM](https://us1.discourse-cdn.com/bubble/original/3X/a/6/a66e744917dd4c9e15b5d38d7216fd2cb1f8681e.png)

 ![Screenshot 2022-05-17 at 4.02.14 PM](https://us1.discourse-cdn.com/bubble/original/3X/f/1/f19b66012f8708b6a6ce7879df87ece5873f3e77.png)

You can review the implementation here: [Double-trouble-bubble | Bubble Editor](https://bubble.io/page?type=page&name=ex1&id=double-trouble-bubble&tab=tabs-1)

---

<div class="post-metadata">

**Author:** ![triplog](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@triplog](https://forum.bubble.io/u/triplog)\
**Post date:** [May 18, 2022, 9:08am UTC](https://forum.bubble.io/t/repeating-group-sorting/207087/3 "2022-05-18T09:08:41Z")

</div>

Thanks a lot for you’re answer. It worked like a charm.  
Took me some time but i figured it out with you’re example and explanation.  
A lot of records need to be loaded but with ext. vertical scrolling it seems not to be that inefficient .

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [July 26, 2022, 7:31pm UTC](https://forum.bubble.io/t/repeating-group-sorting/207087/4 "2022-07-26T19:31:17Z")

</div>

Closed on July 26, 2022, 7:31pm UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
