Enumerates rows, sort ascending-desc., group by, etc

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: https://replit.com/@EmporioVapori/rowNumber
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 :sweat:, 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.

9 Likes

I like the idea and I think I can help to improve your code.

I know what you mean regarding sorting Date arrays due the date/time format, I suffered almost 3 days when I created my code for it.

So far, my Hell YC is able to sort a date array if it has the format:

  • mm/dd/yyyy (en-US)
  • dd/mm/yyyy (used by Latin America and part of Europe)

and of course, it will have a problem if a date format like this dd-mm-yyyy is processed :face_with_thermometer:

I am going to be out of my city for 3-4 days without my PC but I will be reading this thread and others as always.

Feliz día @Roldy

2 Likes

Happy to do it together!

Hi @Roldy, even it is not as advanced as your YC solution, here an idea for a first level of “dynamic grouping” (for inline list or charts).

2 Likes

Thanks. I will look at it :+1: