Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
How to match array of values to another array of traits?

I need to divide a list of unique traits (for example ["Top","Middle","Bottom"], three of five traits) between sets of different percentages that describe the traits, looking like this:

[
  [
    4.545454545454546,
    4.545454545454546,
    27.27272727272727,
    27.27272727272727,
    36.36363636363637
  ],
  [
    13.043478260869565,
    8.695652173913043,
    26.08695652173913,
    34.78260869565217,
    17.391304347826086
  ],
  [
    33.33333333333333,
    16.666666666666664,
    33.33333333333333,
    0,
    16.666666666666664
  ]
]

where each index of such a set

[
    33.33333333333333,
    16.666666666666664,
    33.33333333333333,
    0,
    16.666666666666664
]

describes the percentage for one of the five traits.

Now I can't just compare for each trait the values with e.g. an Math.max(), cause if there are the same percentages (which is in fact very likely), it can't select randomly, but has to compare the remaining traits, to match the traits to the percentages accordingly. And I just can't think of a way to have this remaining trait comparison.

Edit: An expected output would be, given the traits ["Top","Middle","Bottom"] corresponding to the first three values and the values of the above example [2,1,0]. Where in this array the index matches the trait index and the value the index of the value set. In this case set 3, index 2, would get the trait top, as it has the highest top-value and no other set has a high top value, set 2 the middle value, as its bottom value is lower than the first sets value, and the first set would be bottom, as it has the highest bottom value compared to the other values.

Edit 2: Expected input:

Traits that should be compared: ["Top","Middle","Bottom"]

Input sets of values:

[
  [
    4.545454545454546,
    4.545454545454546,
    27.27272727272727,
    27.27272727272727, // given but not needed, as only the first three traits a relevant in this case
    36.36363636363637 // given but not needed
  ],
  [
    13.043478260869565,
    8.695652173913043,
    26.08695652173913,
    34.78260869565217, // given but not needed
    17.391304347826086 // given but not needed
  ],
  [
    33.33333333333333,
    16.666666666666664,
    33.33333333333333,
    0, // given but not needed
    16.666666666666664 // given but not needed
  ]
]

Expected output:

Distribution of traits across value sets: [2,1,0] (corresponding to ["Top","Middle","Bottom"])

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!