Sort using regex on a field of text type in Query Editor

Certified Associate Developer

I have a table with a field "name" which is of text type. It follows a fixed pattern and all the entries are very similar. The entries contain text and numerical values, e.g. Practice 1, Practice 2, Practice 3, ..., Practice n where n can be any number. I need to sort it in the ascending order of the numerical suffix. 

If I sort it as text only I get something like Practice 1, Practice 10, Practice 2, ..., Practice 9 assuming there are only 10 Practices. However, it has to be sorted as Practice 1, ..., Practice 9, Practice 10 as per my requirement. How can I achieve this?

I have attached a picture of my code in the query editor below. I tried casting name to integer using the tointeger() function like below but it gave me an error saying we can't cast on a field.

sort: {
      a!sortInfo(
        field: tointeger(record.name),
        ascending: true
      )
    }



  Discussion posts and replies are publicly visible

Parents Reply Children
No Data