List Shifter: Reverse, Rotate, Swap and ITERATE (Loop) Over Bubble Lists | Now Part of Floppy

Get the selected category’s position in the list using the indexOf action. On the indexOf complete event, rotate it into the first position by doing shift: rotate (the correct value will be either negative or positive of the found index, I can’t recall at the moment).

Thanks Keith,

I actually went another route than creating a back end workflow. I created a hidden “admin” page that has a “Do every X seconds” action on it. I then rebuilt my ListShifter-related workflows on that page that performs its action, writes the answers to the DB and keeps my DB update to date completely by opening that page one day a week for about 6 hours. My app is seldom used on the weekends and so it’s a great time to expose that page and let it churn for a bit.

1 Like

Hi Keith,

Not sure if I understand correctly.

Step 1: get indexOf - to get the index of the current subcategory that is selected in Index state Podkategorija (subcategory)

Step 2: this part I don’t get. How to put the number that Step 1 finds into the Rotate action from bellow:
image

Or I’m doing something wrong here?
Thank you in advance.

GET INDEX publishes the found index into some exposed state of List Shifter (read the docs). Rotate by that amount.

Hi @keith!

It looks like the list shifter output does not update when data is changed. Could this be a bug?

ezgif-5-19d10e78f1

@Thimo are you just filtering or something? List Shifter updates when the result of its List to Shift expression actually changes.

Yeah was always the case for me as well. This time I am using the Bubble Airtable plugin and inside the list shifter I am filtering an Airtable call using a dropdown. I will send you a PM with an editor link so you can take a look :slight_smile:

EDIT: @Thimo, Looking at your example and thinking about it: Unlike a Bubble “Search for…” which is a “live query” (that is, if the results of the search change, such as some item is removed or added to the db), API data calls (of course), are not.

So, List Shifter will not magically update when you think it should.

So, to force List Shifter to reevaluate its “List to Shift”, fire the RESET action at it. (All that Action does is run List Shifter’s update routine/initialization routine.) Note that you might run into another issue which is that responses from API calls may be cached, so you may need to update your API call with a hashbusting field (like a parameter “Date” where you pass Current Date/Time, but that you don’t send to the external API itself). (I assume you’re familiar with this concept, but FYI in terms of how caching might affect - or be affecting - you.)

EDIT: Another way to make List Shifter more “dynamic” when you need to is to make its source List to Shift a custom state. Now List Shifter will update whenever the value stored in the custom state is changed (via the Set State action).

Can I sort one list by another somewhat related list?

I have a list of Teams.
I would like to sort that list of Teams by a list of Assessments. The Assessment has a relation to the Team. Team doesn’t know about Assessment.

I’m having a hard time explaining this. Let me see if a screencast better explains it:

Hey @rico.trevisan, yeah List Shifter’s SORT action lets you sort one list (the list held in List Shifter’s Original List) by some other arbitrary list (the “Sort By List”). As long as you can construct the Sort By list in such a way that the item at each index corresponds to the item at that same index in the Original List, this will work.

So, in your case you have a list of Teams:

  1. Team 1
  2. Team 2
  3. Team 3

And then you have an expression (or have constructed, using Process List for example) a corresponding list of Maturity scores (where I’ve also supposed a value) like so:

  1. Maturity Score associated with Team 1 (25)
  2. Maturity Score associated with Team 2 (100)
  3. Maturity Score associated Team 3 (50)

When you execute that SORT action (sorting as number, descending), List Shifter’s Shifted List would contain:

  1. Team 2
  2. Team 3
  3. Team 1

Now, one weakness of the SORT action in List Shifter is that the sorted “Sort By” list is not published. This would have been handy in some cases, but I was tired of adding new outputs to List Shifter. Typically this isn’t an issue, as often SORT is used just for visually organizing a list in a Repeating Group (as you are doing) and typically the “sort by” list values will be visualized there as the result of some scalar expression within the cell.

In my example, the sorted Maturity values would be [100, 50, 25]. And if you needed that list you’d just take whatever expression you used for the Sort By list and do :sorted (by value descending) on it.

(Aside: There’s a similar action in Floppy - Count Fields/Sort - that can also do the same thing although the sort type is strictly numeric, but it does publish the sorted list of numbers.)

Internally how this works is we create an array of objects where each object is like:

{ original_list_value: Team 1, sort_by_value: 25 }

And then we sort that array of objects by the value parameter and then extract the original_list_values, which are now sorted and those are published to List Shifter’s Shifted List.

Does this help?

The tricky part oftentimes is the construction of that “Sort By” list which you might need to construct using a PROCESS List action (and possibly a second list shifter) and its associated “SET Process FIELD of Interest” action. For an example (not exactly parallel to what you are doing, but that is constructing a list of counts of some associated thing), see:

(and then there’s a bunch of intervening stuff where I create the scenario, but then the punchline is in the following reply)

And then here:

The type of scenario described above is quite common, which is why I created the “Count Fields/Sort” action in Floppy (which makes it super easy to get a list of counts and then sort by them). However, in your case you might need to iterate over your Teams and Assessments lists to match each team with its associated Assessment’s Maturity score (though perhaps there is a native Bubble expression that gives you that).

3 Likes

Wow, rock 'n roll answer! Muito obrigado.

How would I go about this? Should I use List Shifter’s Processed List? Or do you think it would be best to shift over to Floppy instead?

About Process List, I haven’t wrapped my head around it completely. How should I use it? Is it something like

  1. iterate over the ListShifter Teams
    1. do a search for the matching Assessment, add it
    2. add it to the Processed List --or-- should I add it to another List Shifter, or a state?
  2. Sort ListShifter Teams by Processed List

I figured it out!
(this post has that “kid coming to show daddy my new drawing!” vibes)


[update]

Bubble is Bubble’izing the list and not adding extra 0s. I should have known this. Trying some hacky work-arounds.
Tried with List Pusher, but that’s a bit slow (since it’s server-side).
Got it working by creating a string instead of a list of numbers… :man_facepalming:

2 Likes

he was too busy wondering if he could
instead of wondering if he should

CleanShot 2023-02-01 at 17.14.27

No way this is sustainable, but – gosh darn it!! – it works.

3 Likes

Hey @rico.trevisan - attaboy! :tada: A couple of suggestions (well, basically one):

To work around the “states won’t support duplicate values / 0 problem”, use List Shifter’s Custom List feature. First, select the type for the Processed/Custom list in the main property inspector for List Shifter (you’ll want to use number type, of course).

Now you can use the SET Custom List action in your iteration workflow instead of a custom state. Note that that action can either set an entire list or simply append a scalar value (which is what you’ll want to do - read the docs for the various options).

The Custom List supports duplicates and you can do the same trick of substituting 0 for empty as you did with a custom state. Additionally, the Custom List is only published when you say so. (You have to set the “publish” option to yes.)

So you can make your iteration flow significantly faster by appending your maturity scores to Custom List (without publishing it) and then, on the Iteration Complete event, PUBLISH Custom List. Now it becomes available to you as List Shifter’s Custom List.

(The reason this is faster is that publishing values is synchronous and takes some time. By waiting to publish your Custom List until it is fully constructed, you’ll find that the Iteration takes much less time.)

So I’d say definitely give that a shot as you’ll find much better performance!

As for PROCESS List, it’s basically its own little no-code environment. And, actually, it wouldn’t help in this case because you really do need to do a database lookup to get each maturity score and match them to the Team(s), so Iterating via a Bubble workflow was the right approach.

1 Like

Hi @keith, the List Shifter looks really cool! I am wondering if I can use it for this case:
I use external API call to save list of products, corresponding prices and offer ids. Then I run API workflow to save these lists into database so that I can sort the products by price. I also run API workflow which adds more data to each product from external API call (offer id is a parameter).
I want to completly avoid to use database because it is very slow and all the data are temporary (it’s used in chrome extension). Can this be done using the plugin?
Thanks!
Petr

Hello.
When I try to do a ‘make change’ action on several thousand items of data using List Shilter, the data is not updated (sometimes only about 100 items are updated, sometimes only about 100 are updated).
In the debugger, I get the following error.

It works for thousands of “Create actions”, but “Make change” does not work.
Thank you in advance for your help.

Thanks for the plugin it is great.

Just one feature request. Could we sort on multiple related fields?

I have a table that contains a supplier field, a category and a group. I would like to sort by supplier.name, category.name and group.name

Is that currently possible?

Thanks in advance,
Juan

Hey @yumays020201, as I’ve noted in other responses and on the original video about Iterate, you can’t do this unless you’re VERRRRY patient.

The Create and Make Changes actions (which, obviously, interact with the database) appear to complete instantaneously, but they take time to complete on the backend. Sending thousands of such requests to your database in a few seconds can easily cap out your app OR take hours to complete and the pending operations will fail if you leave the page.

List Shifter is not for this use case.

Hey @bubble92, no List Shifter’s SORT action does not support secondary or tertiary sort criteria at present and it’s somewhat unlikely that such a feature would ever be added.

I’ve often thought of building a separate plugin(s) for more robust sorting capabilities, but I really feel such things should be actions, not actions in an element plugin, and the client-side action plugins API doesn’t (yet) support returning values. So this isn’t something I’ve pursued.

Have you looked into sorting on supplier and then using Bubble’s native :grouped by operator? That might get you close to what you want.

Thanks for the reply!
I understand.

1 Like