I always try to imagine the rows in a table do not have an order by default. Of course, visually, one row is above another, so they feel sorted. And Glide does give you a ‘Sort by sheet order’ and ‘Sort alphabetically’ in the Layout Editor, which is kind. But the way I see it, it is up to us developers to add sort attributes (columns) in the table along which we will sort a collection. Sort alphabetically and sort by sheet order are just a luxury.
Let’s say you had the following table:
Pear
Orange
Apple
By default, Glide will offer sort options:
- Alphabetical: Apple, Orange, Pear
- Sheet order: Pear, Orange, Apple
How would you get the order ‘Orange, Apple, Pear’? In the table, add a ‘Sort’ basic text number column. In that column, insert numerical values to determine the sort order.
Pear | 3
Orange | 1
Apple |2
Developers start sort indexes from zero, so you could also do:
Pear | 2
Orange | 0
Apple |1
You could also use the indexes 20, 00 and 10. Or the letters c, a, and b. I hope you get the idea. Really, it’s more logical to use numbers, starting at 0 or 1 in increments of 1, that you will sort in ascending order.
Why a basic text column and not a basic number column? I’m not too sure, I tend to use number columns if I will actually use them to do math. Imagine a phone number or a social security number: the information is made of numbers, but no math will be performed on it. These objects are called numbers, but really they aren’t really numbers because a number is an object you perform math on. If a “number” will be used as text, I tend to store it in a text column. I don’t think it makes much of a difference, but developers might disagree.
EDIT: Jeff points out that it actually is important to use a numerical column for sorting. Explanation.
Finally, sort along this ‘Sort’ column in ascending order.
In short: create a ‘Sort’ text column, place your sorting numbers in this column, and sort along this column.