Skip to content

Commit a215ded

Browse files
authored
Create 2418-sort-the-people.js
1 parent 34b185e commit a215ded

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

2418-sort-the-people.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {string[]} names
3+
* @param {number[]} heights
4+
* @return {string[]}
5+
*/
6+
var sortPeople = function(names, heights) {
7+
const n = names.length
8+
const arr = []
9+
for(let i = 0; i <n; i++) {
10+
arr.push([names[i], heights[i]])
11+
}
12+
13+
arr.sort((a, b) => a[1] - b[1])
14+
arr.reverse()
15+
return arr.map(e => e[0])
16+
};

0 commit comments

Comments
 (0)