ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Sorting by custom number field not working

February 18, 2010 7:27am

Subscribe [2]
  • #1 / Feb 18, 2010 7:27am

    Roku

    5 posts

    This question may be related to a resolved thread.


    Hello everyone,

    I am posting about an issue with sorting by custom number field not working. I noticed someone had posted a similar question where they were trying to sort by a custom field and that bug had not been addressed till recently. I also noticed that the moderator posted that this bug has been resolved to an extent but it cannot handle numbers as well.

    Is there ANYWAY for you to look into this further to have that possible as well?


    Thanks!

  • #2 / Feb 18, 2010 11:14am

    Robin Sowell

    13255 posts

    I suspect you may be running into a different issue- is this sorting within a related or reverse related tag?  That’s the only place the prior bug was in effect.  It was addressed by basically sorting fields that we know are numeric with a sort that handles number well.  Other fields use a different sort- a little less ‘natural’ in their handling of numbers, but it handles spacing a a ‘human readable’ way.

    However- that only applies within related/reverse related tags- which are a bit special.  If it’s the sorting of a weblog tag’s main results?  You’re probably running into the fact that custom fields are defined as strings- sorting is handled by the mysql query, and since they are strings, they’re handled as such.  It’s not a bug- simply a result of how custom fields work.

    That said- 2.0 does add some new field types- include numeric fields.  Which- will sort as numbers.  In 1.6 this isn’t the case.  Though there are some workarounds.  Let me know if this is what’s going on- and I can point you toward some options.

  • #3 / Jul 09, 2010 3:09pm

    Helen Chen

    30 posts

    What options are in 1.6.X?

    Thank you,

    Helen

  • #4 / Jul 09, 2010 3:22pm

    Robin Sowell

    13255 posts

    k- the best way to handle it right now?  Is to… say you know numbers will have at no more than 3 digits- no decimal or anything?  Then instead of 10- enter 010 or 8 would be 008.  Which- I grant is a bit tedious and if it was for a client site, I’d likely write an extension that gets the number into the format I want.

    Some folks used to change the db field type- but it’s a hack and particularly w/2.0 upgrades coming up, I wouldn’t go that route.

    Hope that helps!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases