Forum Academy Marketplace Showcase Pricing Features

Merge with and sort

I am trying to figure out the logic for merging 3 searches and sorting the final merge. Currently if i sort on the last search in the merge it only sorts that search. If I sort individually it sorts the items individually but not on the whole.

Does anyone know how to run a sort on multiple search merges?

I believe you would do your first search, then merge the second and then merge the third…after that dynamic expression is completed you would do ‘add more’ and select :sorted

Weirdly, I don’t think that’s right. Putting the sort at the end only seems to sort the last mini-list in the merge, not the entire mega-list. @zachenson did you ever figure this out?

I’m trying to merge two lists for a workaround for “or”-logic filtering a mildly complicated RG. You cannot do ListA:filtered mergedwith ListB:filtered because Bubble reads it as (ListA:filtered mergedwith ListB):filtered.

I thought I found a solution by using workflows to store the filtered Lists A and B in separate states. I then set the data source on the RG to StateA mergedwith StateB:sorted, assuming that Sort would behave the same way as Filter and apply to the final merged list. Nope! Bubble seems to treat them differently, so I’m stuck with (StateA) merged with (StateB:sorted).

I assume I’m missing something obvious because it’s very strange that Sort and Filter would have such different logic.

Yes that is correct. It only sorts the final search, not the entire merged list which is a bit ridiculous.

You could try to use the List Shifter Plugin to create one list from the two filtered lists and then in the RG put the list shifter list with a sort.

So I played with some different conditions and it would sort the entire list when the list was relatively short, like 10 items. But when the list got long, it wouldn’t. Maybe it’s performing the sort a certain amount of time after the merge, so maybe the merge hasn’t finished when the sort starts on longer lists? Maybe it’s more about when the repeating group starts loading its list? Maybe it’s just that long lists are more prone to issues. I don’t know. I ended up finding another way using states, but I appreciate the reply.

What was that way?

I used subtraction instead of addition. In my case, I could create a List C filter, which was the things that were meant to be excluded by my original List A and B filters. I stored List C as a state on the RG whenever the dropdown I used to choose the filtering options was changed. Then a conditional on the RG changed the data source based on the dropdown’s value. The data source became: “Full List:sorted minus RG’s List C state”. Since the full list was already sorted the way I wanted, the subtraction just removed pieces while preserving the same order.

All of this was to solve another common RG frustration in the forums: you can’t sort a list of things based on another thing’s attribute. I’m building a quiz app and I create Student Answer things that store Answer Key things so that I can edit answer keys without needing to copy all of the new info into every single student answer of that question. I wanted to sort a list of Student Answers by the attached Key’s section number, then question number. Huge PITA. Ended up just putting the question and section numbers on the Student Answer and letting any mismatches be tomorrow’s problem.

1 Like