Reverse order of lists

I have a relationship between two data types tracking using a “This field is a list (multiple entries)” method.

So I have a list of items:
Item 1, Item 2, Item 3

By default the repeating group will display them in this order: 1,2,3

How could I flip the order of this list / display the last item first?
3,2,1 is the desired output.

Append :sorted to your list and then pick the field you want to sort on Created Date (or whatever other column you have available on your list)

Example:

1 Like

The trick here is that the order in which the users added the items to the list is important. I want to essentially show them the results of their last two additions to the list.

This almost does what I want. It grabs the right two items, but I still want to reverse the order of display.

Current Users datatype saveditems:items from # (Current Users datatype saveditems:count - 1)

As I said used sorted. If the order they were added is the important piece then use the Created Date field in desc order

1 Like

It would sort by the saved items created date. Not the date the list item was added to the list. There would be two very different results.

I understand what you are indicating to do. I appreciate you taking at look at this as well.

Edit: I am using the observed behavior that bubble appends the most recent item added to the list at the end of the list. I was going to rely on that for this particular solution but that may not be the best way. Still, I would like to know how to reverse the display of a list as there seems to be a missing function here.

If you want to track when an item is added to a list you are going to have to do that manually. Bubble doesn’t provide this type of functionality out of the box. I can think of several easy ways to solve this problem. If you are only ever going to be looking for the last two items then save the last two in separate fields in addition to the list.

So you would end up with:

Data Type’s Saved Items (The full list)
Data Type’s Last Item Added
Data Type’s Previous Item Added

Then anytime you update the list with a new item in your workflow set
Data Type’s Previous Item Added = Data Type’s Last Item Added
Data Type’s Last Item Added = {New Item’s Value}

If you don’t like that idea, add another field on your data type for “Date Added” and sort by that date. If you don’t like that idea add an entirely new data type and add each list item with an entry date of when it was added and use a query to restrict the results to the last two items from that particular list.

This is how I would approach your problem. I’m sure there are other solutions as well.

2 Likes

Just want to note that this was a question about list manipulation not database design.

Bubble gives me this list: 1,2,3,4,5
I want to output the list in this order: 5,4,3,2,1

Only method I have found to do this is attach an ID to the field (btw this is not default- you have to enable this option in the site settings first) and use a paid plugin to get this to work.

While this is a completely functional solution, it is just baffling such a typical string function (reverse order of list) would require a paid solution.

As for the plugin, seems you have to leave it set to display on the page. When I made it invisible, it stopped working. It doesn’t show anything but takes up space in the layout. A bit awkward but I will find a place for it I guess. I didn’t mind buying the plugin as it was already planned for a future part of the site and was highly recommended.

Edit: Another option has been located. I have not tested the solution but this looks like it was built around the exact idea of what I was trying to do here. Posting in case it helps someone else looking for the solution to this.

1 Like

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