Sorting Things from a RG based on DATE does nothing

Hi,

On my page I have a var_A which is a thing that holds a [list of B]. (var_A → do a search for ..)

On my page I have a var_B which is the list of B from var_A. (var_B = var_A.list_of_B)

Now on my page I have a RG and it displays Bs from var_B.

I can sort it based on name or other text fields. But sorting based on creation_date or modification_date does NOTHING.
What am I missing?

Thanks

PS: I can’t give an app link as I am moving quickly with the app and can’t secure a demo page

EDIT : there are actually a lot of un-answered messages on this matter on the forum.

Hi, The issue is that when you assign var_B = var_A.list_of_B, you’re basically creating a static list on the page. Bubble can sort text fields easily in a repeating group, but sorting by creation_date or modification_date only works reliably when the source is a search result, not a pre-fetched list.

A common solution is to skip the intermediate var_B and do a search for Bs that meet your criteria, then sort that search by creation or modification date directly in the repeating group. Alternatively, if you really need to use var_B, you’d have to use the :sorted operator, like var_B:sorted by Creation Date, before sending it to the RG.

Hope this helps!

Hi thanks for the answer.
That’s not the solution unfortunatelly.

I should have mentionned what I’ve tried:

  1. Sorting var_B before using it in the RG does not help
  2. Trying to force the sorting locally by using :filter:advanced in the R does not help
  3. Using directly the list from var_A in the RG (var_A.list_of_Bs) does not help

Also, the list inside var_B does not seems to be static as it is still updated in live and getting new items.

If neither :sorted nor using the list directly is affecting the order, it usually means Bubble is still treating the list as an already-loaded list from a single parent thing, which can ignore date-based sorting. One thing you can test is removing the list relationship entirely and instead pulling Bs with a Do a search for B where A = var_A, then sorting by creation/mod date in the RG data source. That forces Bubble to query the database rather than reuse the in-memory list.

If that works, then the issue is the list field on A — date sorting on nested lists can be inconsistent because Bubble preserves the internal list order, not the field values.

Not the prettiest workaround, but searching instead of using the stored list usually makes the date sorting behave correctly.

Hope this points you in the right direction.

I was reading this, and the only reason I can think of that sorting by date wouldn’t work is that all the dates are the same.

Have you looked at the actual dates?

Were they batch uploaded by API?

Or were they all uploaded with a workflow?

If so, the dates are probably all the same, and sorting wouldn’t work.

If all the other sorting works, this would be the first thing I’d check.

Just a thought I had.

Maybe it’s no help, but maybe you could check that?

Hi folks, it is with great shame that after years of Bubbling I have been fooled by myself and forgot about privacy rules.

Privacy rule was set to hide “created at” and “updated” at fields. So, impossible to sort on those.

Thanks for the help.

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