0

I'm trying to 'ORDER BY' a String field which contains numbers. It orders like this:

1 10 2 3 ...

I've tried whith LPAD, VALUE, *1, but nothing works.

THANKS all for ur help!

  • CAST doesnt work btw – Carloss Aug 25 '15 at 8:01
3

Two possible options I can think of right now:

First:

  • Populate a map based on your query results, use this field as Integer key (use Integer.valueOf)
  • Convert the keySet into a list and apply sort
  • Iterate the list and fetch the map for results in sequence

Second:

  • Add a formula field with return type as number and use it in ORDER BY clause.
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.