[Cialug] Alphabetical Sort

Paul Gray gray at cs.uni.edu
Wed Dec 11 19:13:22 CST 2013


On 12/11/2013 07:04 PM, Patrick Mcgillan wrote:
> ms sql and asp web pages

>>> 1.4.1
>>> 1.4.10
>>> 1.4.2
>>> 1.5.1
>>> 1.5.10
>>> 1.5.11
>>> 1.5.12
>>> 1.5.2
>>> 1.5.3
>>> Trouble is, 1.4.2 should sort out before 1.4.10, but because it is a
>>> character field it doesn't. Now that makes perfectly good sense to me,

Does your data contain exactly 2  periods in every field?  If so*, you
can sort thrice using substrings, PRE-pending '0' to the field so that
it is forced to be treated as a numeric field, as in
  ORDER BY '0' + SubstringDigits

(*) If so, then I'd attempt to work up a MySQL command that would do
what you want.

-- 
Paul Gray                                         -o)
314 East Gym, Dept. of Computer Science           /\\
University of Northern Iowa                      _\_V
 Message void if penguin violated ...  Don't mess with the penguin
 No one says, "Hey, I can't read that ASCII attachment ya sent me."


More information about the Cialug mailing list