我有一个按进球数排序的球员数组:
let players = [
{"name": "player1", "goals": "5"},
{"name": "player5", "goals": "4"},
{"name": "player2", "goals": "4"},
{"name": "player3", "goals": "2"},
{"name": "player4", "goals": "1"}
]
我想按照表格位置显示这些数据,就像这样:
- 选手1 - 5个进球
- 选手5 - 4个进球
- 选手2 - 4个进球
- 选手3 - 2个进球
- 选手4 - 1个进球
如何添加这种“按数组顺序排名”的类型(我不确定这是否是描述这种类型的好词)?