[dba-SQLServer] sorting problem

Billy Pang tuxedo_man at hotmail.com
Mon Nov 1 01:00:09 CST 2004


Hi Arthur:

>Fine! Fine! Fine! In future, I suggest that you provide your third-world 
>developers with an adequeate data set. LOL. I shall go back to the salt 
>mines and toil endlessly until I have a solution. But you still haven't 
>made the rules quite clear, if I may say so, Sir.

Perhaps my original approach to the sorting problem could be improved.  I 
can't really define all the rules because they are not set yet and if they 
are set, the rules tend to get changed on me.  Looking at my original post, 
I posted sample data but did not provide enough explanation on what I was 
really looking for (how to sort letters before numbers where the "no 
character" takes precendence over "existence of a character").  (like eating 
dessert before the main course).  Sometimes, to communicate more 
effectively, we should explain the issue first with more words and provide 
example afterwards.  The other way around, though allowed, is not that 
effective.

Anyways, I was looking for an "all covering" "all knowing" solution to 
"sorting values where letters take precendence over numbers and where the 
"no character" takes precendence over the "existence of a character""; 
something simple that did not require hardcoding the solution.  I didn't 
know if such exists but you never know unless you ask and I wanted to make 
sure that I wasn't overlooking anything obvious (can't see the forest 
because of all these trees).

>Given strings x##x#x and xx###xx#xx, please define the desired sort order.

x##x#x would come first, then xx###xx#xx.  :P (running towards the forest)

>I think I can do this by sequential calls to the func I wrote, but I could 
>be wrong. I need more evidence to determine how to revise my inadequate 
>contribution thus far.
>

I cannot provide more evidence so that you can revise your code because 
sting values could be anything.  x or x# or x###x or x##x or x#x#x#x# etc...

Please don't call your contribution inadequate.  I believe that all 
contributions contribute in some way to some degree to the solution one way 
or another.  I am reading this book called "Thinking for a change" by John 
Maxwell.  He claims that "one idea + one idea = three ideas".  Even though 
the statement is mathematically incorrect, it is very true because the words 
people say/write usually get other people thinking in some part to generate 
a new idea.  There are many people I respect when it comes to databases; 
some are on this list and some who were but no longer on the list.

Sincerely,
Billy





More information about the dba-SQLServer mailing list