Randomly sort items

Hi everyone.

I know this question seems to have been asked many times and I have read many of the answers but so far non of them have made any sense to me. The response is wither too short or too advanced for my level of knowledge.

As everyone is well aware, in the UX section, there is no option to sort items randomly. Its either ascending or descending. Why such a basic and necessary option is not available in a WYSIWYG app building application is beyond me, but it is what it is.

What I want to know is how and where do I add the simplest expression possible that will display my items randomly. If possible, I would like to know the expression, where exactly to put it and what each every word in the expression means and what will it do.

My app is about a list of hotels from different regions and I need to show them randomly every time the user access the database, because every hotel needs to have a chance to appear on the top of the list, not only the one in the database.

Be aware, I don’t know the jargon, I don’t know the acronyms, I am not familiar with excel expressions. I even have a tough time understanding the logic of how expressions work. In short, I am a visual type of person. If I don’t envision a visual connection, I won’t get it.

If you could help me, I would appreciate it very much.


1 Like

First, “sorting randomly” is an oxymoron. There is no such thing. Sorting is either ascending or descending. Maybe what you mean is to be able to control the ORDER of the items? But it certainly would not be random.

1 Like

First, “sorting randomly” is an oxymoron. There is no such thing. Sorting is either ascending or descending.

Ok, got it!

You want to control the order based on randomly assigned values. To accomplish this you need a dedicated column. maybe named Order, used only for Sorting and then assign random values using the RANDBETWEEN() with a very large range for extra randomness:

RANDBETWEEN(1, 999999999)

Sheet might look like:

Where to put this?

That is the big question and will depend on your app. When do you want the row orders to change?


Thanks for your answer John.

I have a Gallery View of all the Hotels and every time this view is loaded, I want it to be ordered randomly.

So I am really only seeing a single choice to make this happen. Each time the Hotels view is requested, an action is run to re-calc the random value assigned to the Order column before the view is shown.

I would:

  1. Create the Order columns as described above setting App Formula = to the RANDBETWEEN() funcion.
  2. Create the Hotels Gallery view as a Ref view, i.e. it cannot be accessed as a main view or a menu view… it needs to be one reached by some action. Sort it by the Order column.
  3. Create a grouped action to:
    a) first - re-calcs the Order value for each Hotel row.
    b) second - navigates to the Hotels View.

This grouped action could be a button that is tapped directly, referenced by other actions or Row Selection behaviors or integrated into other processing you have.

The only caveat is that you probably want to re-calc on thousands of rows of hotels. I don’t know how many you have. I imagine if you have a large list, you would somehow be reducing that list shown to the user. It is this reduced list you want to re-calc the Order Value on.