Sorting by Number

4 posts by 3 authors in: Forums > CMS Builder
Last Post: August 29, 2008   (RSS)

By InHouse - August 28, 2008

I would like to sort the records in a Section Editor to be displayed based on the order of a text field in that Editor. This field will only store integers.

When I sort by this field, the sorting is that silly format where it looks like:

11
12
13
1
2
21
22
23
3
etc.
Is there any way around this? I don't want to have to enter 01 instead of 1.

Cheers,
J.

Re: [InHouse] Sorting by Number

By Dave - August 29, 2008

There's lots of ideas in that thread Kevin suggested. I usually use: ORDER BY fieldname+0

And that forces it to be a number. It's because it's sorting them alphabetically and not numerically.

Let me know if the fieldname+0 or one of the other solutions works for you.
Dave Edis - Senior Developer
interactivetools.com