Here's my terribly hacky version of Ryans;

a=$<.read.split("\n");s=%w{d c h
s};c='AKQJT9';t=a.shift;u=(t[0]+32).chr;i=s.index(u);v=s[i-2];w=[1];4.times{|j|w<<s[j-i]};puts
t,a.sort_by{|k|k=~/J[#{u}#{v}]/?$1?0:1:w.index(k[1,1])*10+c.index(k[0,1])}

On 11/21/05, David Balmain <dbalmain.ml / gmail.com> wrote:
> Ryan, how about changing /(J#{u})|(J#{v})/ to /J[#{u}#{v}]/? That'll
> save you a couple more characters. :p
>
> On 11/21/05, Ryan Leavengood <leavengood / gmail.com> wrote:
> > Thanks to inspiration from reading Zed Lopez's code, I've been able to
> > cut my golfed solution from 242 bytes to 214. Unfortunately for you
> > Zed, this now means your is now 108 bytes longer :)
> >
> > The fixes were:
> >
> > 1. Using s[x,1] instead of s[x..x] to get a single character from a
> > string. This saved 2 bytes.
> > 2. Calculating the weights INSIDE the sort_by, instead of using a
> > separate hash. This seems so obvious now I slapped my head when I saw
> > Zed's code doing this. This saved a whopping 26 bytes.
> >
> > So, if anyone is interested:
> >
> > a=$<.read.split("\n");s=%w{d c h
> > s};c='AKQJT9';t=a.shift;u=(t[0]+32).chr;i=s.index(u);v=s[(i+2)%4];w=[1];i.upto(i+3){|j|w<<s[j%4]};puts
> > t,a.sort_by{|k|k=~/(J#{u})|(J#{v})/?$1?0:1:w.index(k[1,1])*10+c.index(k[0,1])}
> >
> > I will be highly impressed if someone can go shorter than this. Also
> > if anyone wants it I can post a message "decoding" the above.
> >
> > Ryan
> >
> >
>
>