I wrote this function to offer some support on sequential numbering.
However, the function is not limited to simple numbering but also has the following features:
- can sort rows in ascending or descending order
- can group rows and sort them within the group
- can sort by number, by text, and by case-insensitive text.
Of course, with ‘sort rows’ I don’t mean the physical reorganization of the rows in the table but simply the generation of an index that can be used for this purpose (which is what the function returns).
Parameters:
RowId: typically Glide’s RowId column but can be any unique key
Separator Char: is the separation symbol(s) that is used for the following Joined List columns
Joined Row IDs: is the join-list of all RowIds
Joined column to group by: is the join-list of the column that you intend to use for grouping
- if empty, no grouping is considered
Joined column to sort by: is the join-list of the column that you intend to use for sorting
- if empty, no sorting is considered
Sort type: is the type of sorting to apply (represents the data type of the column to be sorted):
n = numeric
t = case sensitive text
u = case insensitive text
Backwards order
if set to true it sorts in reverse
To fork: rowNumber - Replit
To use: https://rowNumber.emporiovapori.repl.co
NOTE
This function is quite complex and I think it is heavy on the device side (I am not fully aware of it, because I use a very fast PC), that’s why, with great effort , I avoided the use of for loops to save as much processing time as possible, but I have not yet had the opportunity to test it on many rows; please help me in testing or fine-tune it if you are interested in this topic and this pleases you. In any case, please keep in mind that this is the very first version of this feature, try it but don’t use it in critical applications!
If it is worth it, I can study how to deal with the problem of sorting dates, which is not at all easy due to the very variable format; it would probably be a good idea to adapt them to the UTC format and then sort them as if they were normal text strings.