On Jul 23, 2010, at 5:39 PM, DJ wrote:

> I have sorting problem with a column in the database (string) that
> stores alphanumeric data. The data is A1, A2, A3..A10, A11, A12.
> 
> When I sort by column type, I get A1, A10, A11, A12 but I would like
> to get A1, A2, A3...A10, A11, A12. Is there anything I can try with
> orderby="columntype"? What other kind of operations does orderby
> allow? (I saw field.upper and field.month).

What you're looking for is a natural (as opposed to lexical) sort, which most 
(all?) databases lack.

A common solution is to create another column to serve as a sort key. In your 
example, it might be A01, A02, ... A10. Or two columns, one with the leading 
alpha, sorted lexically, and the other with the number, sorted numerically (and 
a two-column major-minor sort).

Reply via email to