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

Hey @gavin1: Well, thank you for your support!

So there’s a much faster way to do this (and sorry it’s taken me a while to respond). You’re correct that it involves the SORT action.

What we would do is take a list of random values (52 if you have 52 cards in your deck, for example) and then SORT the deck by that list.

List Shifter makes this super easy, and I’ve created a demo page for you:

https://list-shifter-demo.bubbleapps.io/version-test/mapped-sort-shuffle-cards?debug_mode=true

The editor is here.

There are actually 2 “random” functions in List Shifter and I demonstrate using both on the demo page:

  1. As you noticed, you can actually call Math.random() as an operand. This gives us a reasonably random list of number to sort on. (I should probably add a random option that uses the higher-entropy browser crypto functions to do this, but haven’t bothered to yet.)

  2. There’s another random function in List Shifter (it’s one of the operators) called nanoid(x). Nanoid is small little library that I use all over the place and so included it in List Shifter. It makes random, URL-safe strings that are extremely high entropy (they are very random) and leverages the crypto random functions for that. Nanoids are sort of a replacement for UUIDs (which have certain benefits over UUIDs). But in this case we can abuse them for their high randomness! :slight_smile:
    Instead of creating a list of random numbers, we can create a list of these random strings and then use that as our sort list (selecting “Text” as our sorting technique):

Once we have our list of 52 random things, we just sort using that list using the SORT action:

In the numeric case:

In the text case:

1 Like