Sort Data by Group !

Hello,

I have a file and i want to sort by third column and extract the three top lines of each group, it is determined by the second column (144, 89, 55, etc).

Could you please help me with the appropiate awk shell script

      XLY-XLP   144   0.592772       XLY-XLE   144   0.798121       XLY-XLF   144   0.682582       XLY-XLV   144   0.762279       XLY-XLI   144   0.893199       XLY-XLB   144   0.908553       XLY-XLK   144   0.902004       XLY-XLU   144   0.393566       XLP-^FTSE   89   0.85931       XLP-^N225   89   0.65297       XLP-USO   89   0.778344       XLP-UUP   89   0.464081       XLP-GLD   89   -0.7242       XLP-SLV   89   -0.38121       XLP-GXG   89   0.630136       XLP-FXE   89   -0.05132       XLP-SLV   55   -0.36012       XLP-GXG   55   0.717349       XLP-FXE   55   -0.00732       XLP-EUO   55   0.148117       XLP-KOL   55   0.846785       XLP-HAL   55   0.700265       XLP-ORCL   55   0.856371       XLP-C   55   0.806475   

Sincerely,

Carlos

Take the trouble and give example of needed output.

Hello,

I have a file and i want to sort by third column and extract the three top lines of each group, it is determined by the second column (144, 89, 55, etc).

Could you please help me with the appropiate awk shell script

Data:
XLY-XLP,144,0.592772
XLY-XLE,144,0.798121
XLY-XLF,144,0.682582
XLY-XLV,144,0.762279
XLY-XLI,144,0.893199
XLY-XLB,144,0.908553
XLY-XLK,144,0.902004
XLY-XLU,144,0.393566
XLP-^FTSE,89,0.85931
XLP-^N225,89,0.65297
XLP-USO,89,0.778344
XLP-UUP,89,0.464081
XLP-GLD,89,-0.724198
XLP-SLV,89,-0.381205
XLP-GXG,89,0.630136
XLP-FXE,89,-0.0513242
XLP-SLV,55,-0.360124
XLP-GXG,55,0.717349
XLP-FXE,55,-0.00732295
XLP-EUO,55,0.148117
XLP-KOL,55,0.846785
XLP-HAL,55,0.700265
XLP-ORCL,55,0.856371
XLP-C,55,0.806475

Output required:
XLY-XLB,144,0.908553
XLY-XLK,144,0.902004
XLY-XLI,144,0.893199
XLP-^FTSE,89,0.85931
XLP-USO,89,0.778344
XLP-^N225,89,0.65297
XLP-ORCL,55,0.856371
XLP-KOL,55,0.846785
XLP-C,55,0.806475

Sincerely,

Carlos

sort -t, -k2,2nr -k3,3nr infile | 
  awk -F, '_[$2]++ < 3'