It's not uncommon for my apps to have a requirement where a user is given the ability to sort data in a grid by clicking on column headers. The usual problem I've encountered with this requirement is when I have to sort a numeric column that's represented as a string. The following table compares the numeric and string sort:
| Numeric sort | Numeric string sort |
| 1 | 1 |
| 5 | 10 |
| 6 | 150 |
| 10 | 20 |
| 20 | 5 |
| 150 | 6 |
So if I had a column that was stored numerically and had to represent that column with a unit of measurement, i.e. 150 GB, the sorting would be messed up.
A workaround I used recently was to include that column twice in my SELECT statement, one as numeric and the other as a CAST to string/char. Then I'd show the string column in my grid and hide the numeric one. But whenever I sort, I use the numeric one.

