Who wins a Spades trick Write code to determine who wins a four-card trick in a game of Spades. Fewest bytes wins.

The input is a string that lists the four cards played in sequence like TH QC JH 2H (Ten of Hearts, Queen of Clubs, Jack of Hearts, Two of Hearts). A card is given by two characters: a suit from CDHS and a value from 23456789TJQKA. You are guaranteed that the input is valid and the cards are distinct.

You should output a number 1, 2, 3, or 4 for the winner of the trick. In the example TH QC JH 2H, the jack of hearts wins the trick, so you should output 3.

Your input and output must be exactly as described, except trailing newlines are optional.

Here are the Spades rules for winning a trick. The winning card is the highest card of the four, with some caveats. Spades is the trump suit, so any spade outranks any non-spade. The suit of the first card played is the lead suit, and only cards of that suit or spades are eligible to win the trick. Cards of the same suit are compared by their values, which are given in increasing order as 23456789TJQKA. 

Test cases:

TH QC JH 2H
3
KC 5S QS 9C
3
QD 2D TD 5D
1
9S 5D AD QS
4
3D 4C 3H JH
1
9S 4S TS JS
4
5H 9H 2C AD
2
5S 4C 3H QD
1
2H 2S KH AH
2
Pyth, 28 27 25 bytes

J"KTAZ"hxcz)eo_XN+@z1JJcz


Try it online: Demonstration or Test Suite (first 4 chars are the test suite construct)

Thanks to @isaacg for a trick, which saved 2 chars. 

The main idea is to modify chars of each hand such a in way, that the winning hand has the maximal value. 

The values of the hands 23456789TJQKA is already nearly sorted. I just have to replace T with A, K with T and A with Z, resulting with 23456789AJQSZ. 

The order of suits CDHSare for the most not really important. S, the most powerful suit, which is already the maximal value. Important is to give the suit of the first hand the second most powerful value. So I translate this suit into K. 

All hands also have to be read reverse, since the suit is more powerful than the value. 

                           implicit: z = input string
J"KTAZ"                    J = "KTAZ"
             o         cz  orders the hands N of split(z) by:
              _              the reversed of 
               XN+@z1JJ      N, where the values z[1]+J are replaced by J
            e              last element (winning hand)
        xcz)               index of the winning hand in split(z)
       h                   + 1