/*
* @lc app=leetcode.cn id=2418 lang=typescript
*
* [2418] 按身高排序
*/
// @lc code=start
// @lc code=end
function sortPeople(names: string[], heights: number[]): string[] {
return [...new Array(names.length).keys()].sort((a, b) => heights[b] - heights[a]).map(i => names[i])
}
test.each([
{ input: { names: ['Mary', 'John', 'Emma'], heights: [180, 165, 170] }, output: ['Mary', 'Emma', 'John'] },
{ input: { names: ['Alice', 'Bob', 'Bob'], heights: [155, 185, 150] }, output: ['Bob', 'Alice', 'Bob'] },
])('input: names = $input.names, heights = $input.heights', ({ input: { names, heights }, output }) => {
expect(sortPeople(names, heights)).toEqual(output)
})