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

111
Views
How do I sort a javascript 2d array of names into groups?

I have a race consisting of (for example) 9 heats. There are (for example) 9 drivers split in to groups. In this example, each driver will drive in 4 heats each. However, I don't know ,explicitly, how many groups there are and I don't know how many drivers are in each group.

What I do know, is which heat each driver is in. So, for this example the heats may look like this: enter image description here

So, how do I determine how many groups there are and how do I get the drivers in to their respective groups?

Also, how do I make this generic, so that it could be 8 drivers in 8 heats or 37 drivers in 29 heats?

In javascript, so far, I have populated a 2D array that gives results similar to the grid shown above.

Here is the code I have so far:

for (var i = 0; i < heatData.cnt; i++)           //number of heats                                              
{
    var driverArray = new Array();
    for (var k = 0; < json.r[1].d.length ; k++)  //number of drivers in this heat.
    {
        var name = json.r[1].d[k].nn;            //this is the name of the driver in this heat.
        driverArray[k] = name;                   //adds the name to the inner array
    }
    heatArray.push(driverArray);                 //adds the inner array to the end of the outer array.
    });

}

Thanks,

Connal

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!