[rt-users] Sorting by CustomField

Ruslan Zakirov ruslan.zakirov at gmail.com
Wed Sep 2 07:04:52 EDT 2009


On Wed, Sep 2, 2009 at 12:55 PM, Lars Thegler<lars at thegler.dk> wrote:
> On Tue, Sep 1, 2009 at 4:26 PM, Jerrad
> Pierce<jpierce at cambridgeenergyalliance.org> wrote:
>>> However, in this case, we have a numeric custom field, and the default
>>> Ascending sorts '10' before '2'. Any hint on how to specify numerical
>>> instead of alphabetical sort order?
>>
>> Pack the single digits with a leading zero.
>
> Good workaround, but ugly. Also, the length of these numbers is not
> upwardly bounded, so I'd have to prepend a lot of zeroes to be sure of
> the sorting.

Below I suggest two solutions, but both need coding and can not work
for arbitrary long numbers.

> Maybe there's a way to prepend zeros, do the sorting, and the remove
> the zeroes before display?

There is way to append zeroes before storing in DB and strip them
before showing value.

> Am I to assume there is not way to specify the sorting, numerical vs
> alphabetical?

There is way - CAST function.

First solution can store up to 255 digits and sort by them, but using
full length of the field will slow down sorting and DB would be much
bigger. Second solution I like more as it's more proper way to do
this, but number will be limitted by the system(DB, 32bit/64bit).

> /Lars
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com

-- 
Best regards, Ruslan.



More information about the rt-users mailing list