How to achieve queue jumping ranking in the game ranking list?

  java, question
排名 玩家ID
1 001
2 002
3 003
4 004
5 005

If player 004 defeats player 002 with rank 2, the ranking will become

排名 玩家ID
1 001
2 004
3 002
4 003
5 005

The data structure is Map < rank, player ID >
thks! !

Map or list is not used, either ArrayList or LinkedList, because ArrayList is equivalent to an array, and a large number of elements need to be updated when ranking changes. Although LinkedList is convenient to insert and delete, it needs to be traversed to find the changed position because binary search cannot be used. A better implementation is to use Balanced Binary Tree or directly use sortset in redis