Sort text as numbers

Hello Wappler,

  • I have text column in my DB which contains numbers
  • I have Bootstrap 5 generated table which has sorting options

Currently sorting of such column looks like this:

Is it possible to sort such column as numbers so that order of records would be: 33, 44, etc.

That’s is how sorting strings works. If you want to sort these as numbers they need to be numbers.

make sure they are set as INT in your database… and not text or varchar or something…

I’m using text values in order to use “Contains” constrain for filtering.
Well… I guest I just have to chose one: either to have Contains filtering options or Sorting option.

Thank you for clarification.

You could use a repeat on the server to loop through the query results and use a set value with the .toNumber() formatter on the string to convert to number