Forum Academy Marketplace Showcase Pricing Features

Sorting a list by name where the names are numbers saved as a text field

I’ve got an RG that is sorted by the items’s names. This is the list of buildings in the campus. Some times the names of the buildings are proper names. Easy sorting.

Other times the names of the buildings are actually numbers. In this case, when I sort I get:

  • 1
  • 11
  • 12
  • 2

What are some ideas on how to sort this so it’s:

  • 1
  • 2
  • 11
  • 12

I was thinking of a few options, but before trying it, I thought I ask the hive-mind :bee:. Some of the options I was considering were:

  1. There’s probably some regex incantation that does this :mage: .
  2. Merge multiple searches where the first search only returns the items where the name is 1 character, the 2nd is with 2 characters, etc…
  3. there’s a plugin that does this :man_shrugging:?
  4. add a field to my database with the rank which is a number.

What do you guys think?

I vote for option 2.

1 Like

I suggest option 4 as it offers more flexibility for the future. Maybe it’ll come a time when you want to sort them differently and the order field is the best to achieve this.

Best,

Arthur

2 Likes

Are you ever going to sort a search that has buildings with numbers as names as well as regular names

For example a list of buildings like “mess hall, dormitory, 1, gym, 3”

If you are not and you will only ever need to sort a list of buildings whose names are actually numbers but you have them stored as a text and you want to sort them like a number then use the function to format a text as a number and then sort.

Screen Shot 2020-08-02 at 1.57.25 AM

3 Likes

Thanks for all the work, @boston85719 ! I didn’t even know there was a :convert to number!

That was exactly what I needed. Well, thought I needed. As soon as I started displaying the list of buildings I started seeing all the edge cases. I might indeed, follow @arthur.kieffer’s recommendation and go for option 4. But now I know how I can get those names:converted to number.