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.

1 Like

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

FYI - had this issue, but the new Parenthesis release appears to have solved sorting of merged searches

I have the same problem. Has it been released already? Where can I find the issue?

@nakano_satoko, if you are asking about the parentheses feature, it is an experimental feature that you can enable by going to the Settings >> Versions tab and checking the box beside Expression parentheses.

Bestā€¦
Mike

1 Like

Thank you, @mikeloc . I could find that.
But, I couldnā€™t understand that how to use parentheses for ā€œMerge with and sortā€ in Repeating Groupe.