Ranking list by value and corresponding name

google sheets

I simply got the same question of this guy, but mine is for google sheet:
https://www.mrexcel.com/board/threads/ranking-list-by-value-and-corresponding-name.47862/

I just tried to convert the formulas from Excel to Google Sheet, but there is always some errors that I can't fix.

For my ranking (A2:A13) of number of chips (D2:D13), here is my formula:

=RANK(D2;$D$2:$D$13)+COUNTIF($D$2:$D$13;D2)-1

Now, I want to order this ranking from A2:A13 in a new sheet (H2:I13) with the corresponding player name. As you can see in the picture below. The ranked #1 player on the top to the player #12 on the bottom.
enter image description here

As you can see in H2, I try a formula to make this happened, but I doesn't work. Here are the formulas of H2 and I2:

H2: =IF(ROW()-ROW($H$1)<=$G$1;INDEX($B$2:$B$13;MATCH(ROW()-ROW($H$1);$A$2:$A$13;0)),"")         
I2: =IF(H2<>"",INDEX($D$2:$D$13;MATCH(ROW()-ROW($h$1);$A$2:$A$13;0)),"")

I don't know where is the problem!
Anyone can fix it please?

Best Answer

You are apparently just trying to sort columns B and D by column D in descending order. Try this:

=sort( { B2:B13, D2:D13 }, D2:D13, false )

To get the column headers as well, use query() like this:

=query(A1:D, "select B, D order by D desc", 1)

These are array formulas that create the whole result table in one go.