How to sort nested repeating group

Hey everyone,

I’m using the rss.app API to create and retrieve RSS feeds for my users. Each user on my app has their own feed bundle, which I create using this endpoint: Create Bundle.

In one of my repeating groups, I’m iterating through a list of users, and for each user, I fetch their feed items using the [Retrieve Feed], (RSS API - Retrieve Feed | RSS.app) endpoint.

The problem I’m facing is with sorting the items. Right now, I’m fetching the feed for each user one at a time, and the items are displayed like this:

  • User 1: RSS item (2 days ago)
  • User 1: RSS item (5 days ago)
  • User 2: RSS item (1 day ago)
  • User 3: RSS item (4 days ago)

I need to maintain the association of each RSS item with the corresponding user. Still, I also need the items to be sorted by date across all users, so they appear in chronological order regardless of which user the item belongs to. Sorting is a challenge in this case, as I fetch feeds user by user.

Any advice on how to approach this?

The desired result would be:

  • User 2: RSS item (1 day ago)
  • User 1: RSS item (2 days ago)
  • User 3: RSS item (4 days ago)
  • User 1: RSS item (5 days ago)

I’ve been stuck on this for a while now, and it feels like I’m chasing my own tail. I’m sure this can be achieved, but I just can’t seem to find the right approach. Any ideas or suggestions would be really appreciated!

sort by ascending this will make the data to be presented from earliest to the latest
in your condition, do a search by and set a sort by created date , then the order should be in ascending order

let me know if this is helpful

If you just need to display the data, and don’t need to transform/modify/reference it in any way, you could use format as text to iterate over the results and turn them into one consolidated list of texts. That way you’d only need a single repeating group, avoiding the nested groups entirely.

It’s a useful approach when you need to display multiple datatypes in a single repeating group. I use it on our app to display a consolidated, chronological statement of account to each of our clients, which pulls from several different financial datatypes in our db.

My preference is usually to use pipes “|” (gets a little more complex if you need to use regex) to separate entries, so that they can be split later, making them a little more (if not fully) dynamic in the output, just make sure to keep dates in reverse to allow sorting:

Modified format as text input for rg:

2024-01-01|user_1|feed_item, 
2024-02-04|user_1|feed_item, 
2024-01-02|user_2|feed_item

You then split this block text by comma and feed them into your rg, subsequently splitting out each field by the pipe to display them where you want them in your rg. This can then be sorted ascending/descending, which will go off the date at the start of the string.

Another upside to this method is that it makes for really easy filtering, as you can add in whatever search terms you want into each line, but just ignore them when splitting out what you display.

e.g.

2024-01-01|user_1|feed_item|feed_type|popularity|author|other, 
2024-02-04|user_1|feed_item|feed_type|popularity|author|other, 
2024-01-02|user_2|feed_item|feed_type|popularity|author|other

Even if you ignore everything after “feed_type”, you can still filter the results by checking if they contain the value of an input, which could be the author, popularity, other etc.

Upsides:

  • Consolidated data
  • Less repeating groups
  • Easy date sorting
  • Easy filtering

Downsides:

  • Big loss of data modularity
  • Depending on size it can be a slow operation (I calculate mine server side for that reason)

Wow, thank you. That trick didn’t come to my mind.
Thanks for writing a detailed, possible solution.

I calculate mine server side for that reason
This is the approach I might take.

Another solution would be to create a plugin but not sure if I will have time for it.
Thanks again, I will let you know if this worked out for me!
Have a nice weekend everyone!