Forum Academy Marketplace Showcase Pricing Features

Sorting a repeating group by number of upvotes

I would like to sort (using a dropdown) a repeating group by the number of upvotes from highest to lowest and from lowest to highest. The RG displays a list of products.

I’m able to sort the RG by creation date. Upvotes are set up in the database as a “List of users” so that users can only upvote a product once.

Any help would be appreciated - thank you :slightly_smiling_face:

Link to editor: Product-hunt-clone-bootcamp | Bubble Editor

Screenshot of RG

The easiest way to do this can be to have an element state on the Repeating group that’s a yes/no field for deciding whether the sorting is highest to lowest or not.

The repeating group’s data can have an additional :sorted option to sort by number of upvotes with the value of ‘Descending’ being this state value, set as dynamic data.

Descending: Repeating Group’s isHighToLow

Descending = yes
means that the items will be sorted from highest to lowest and vice versa.

Hope this helps

Ranjit | Blur Apps

@blurapps It sort of makes sense, but I’m still new to Bubble so having trouble conceptualizing it. Would this a custom state? Or how would i set this up?

Custom states are quite powerful!
Here’s a good resource: How to Use Custom States | Bubble.

So basically you can store some temporary data on an element. This data is not persistent, so it will clear off when you refresh the browser.
But you can set up workflow actions in ‘on page refresh’ to set default states on your elements when someone opens your Bubble App.

The link will explain the details better than I can :slight_smile:

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