# 2418. Sort the People ###### tags: `Leetcode` `Easy` Link: https://leetcode.com/problems/sort-the-people/ ## Code ```java= class Solution { public String[] sortPeople(String[] names, int[] heights) { int n = names.length; Integer[] idx = new Integer[n]; for(int i=0; i<n; i++) idx[i] = i; Arrays.sort(idx, (a,b)->(heights[b]-heights[a])); String[] ans = new String[n]; for(int i=0; i<n; i++){ ans[i] = names[idx[i]]; } return ans; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up