title: Laravel sorting a collection (chunking)
body: <p>Most likely a simple question but my head is spinning a bit. Any help would be appreciated.</p>
  
  <p>I am wanting to combine the results from the driver ID's with the route ID's for example the JSON result would be. </p>
  
  <pre><code>"6a": [
   [
      1,
      2,
      3,
      4,
      5
    ],
   "9a": [
    [
      6,
      7,
      8,
      9,
      10
     ]
  
  public function triggerMerge()
      {
  
          $RouteID = Route::all()-&gt;pluck('route_id');
          $DriverID = Driver::all()-&gt;pluck('driver_id')-&gt;chunk(5);
  
          foreach ($RouteID as $key =&gt; $route) {
              foreach ($DriverID as $k =&gt; $driver) {
  
                  $variables[$route][] = $driver;
  
              }
  
          }
      }
  </code></pre>
  
  <p>The above function only combines the chunks to the second index of the array. I am wanting to separate each chunk in numerical order to each index of the first part of the array. </p>
  
  <p>The current result is </p>
  
  <pre><code>variables": {
   "6a": [
           [
            1,
            2,
            3,
            4,
            5
           ],
            {
           "5": 6,
           "6": 7,
           "7": 8,
           "8": 9,
           "9": 10
            },
           {
           "10": 11,
           "11": 12,
           "12": 13,
           "13": 14,
           "14": 15
           },
           {
           "15": 16,
           "16": 17,
           "17": 18,
           "18": 19,
            "19": 20
           },
          {
           "20": 21,
           "21": 22,
           "22": 23,
           "23": 24,
           "24": 25
           },
           {
           "25": 26,
           "26": 27,
           "27": 28,
           "28": 29,
           "29": 30
            }
            ],
   "9a": [
           [
           1,
           2,
           3,
           4,
           5
            ],
           {
          "5": 6,
          "6": 7,
          "7": 8,
          "8": 9,
          "9": 10
          },
          {
         "10": 11,
         "11": 12,
         "12": 13,
         "13": 14,
  
         "14": 15
         },
         {
         "15": 16,
         "16": 17,
         "17": 18,
         "18": 19,
         "19": 20
          },
          {
         "20": 21,
         "21": 22,
         "22": 23,
         "23": 24,
         "24": 25
        },
         {
         "25": 26,
         "26": 27,
        "27": 28,
         "28": 29,
        "29": 30
  
  
  }
  ],
  </code></pre>
  
  <p>any help with this would just be amazing </p>