title: Split array into smaller arrays depending on when a value changed
body: <p>There are several other question like this, but for all this question the sort key is known.</p>
  
  <p>So here is my problem.
  Consider this test class:</p>
  
  <pre><code>class Test{
      constructor(){
          this.value1 = val1;
          this.value2 = val2;
          this.value3 = val3;
      }
  </code></pre>
  
  <p>and here is a compare function</p>
  
  <pre><code>function compare(a,b){
      if(a.value3 &lt; b.value3){
          return -1;
      if(a.value3 &gt; b.value3){
          return 1;
      return 0
  }
  </code></pre>
  
  <p>So when i have an <code>array of Test's</code> f.e. with <code>size 50</code>
  I would sort this array like this.</p>
  
  <pre><code>arrayOfTest.sort(compare)
  </code></pre>
  
  <p>which will return my array sorted by <code>value3</code>. Now i want to split up this big array into several smaller ones, depending on WHEN value3 changes.
  So for example:</p>
  
  <pre><code>arrayOfTest=[a = Test(value3 = 3),b = Test(value3 = 3),c = Test(value3 = 4)]
  </code></pre>
  
  <p>should be split into</p>
  
  <pre><code>array1 = [a = Test(value3 = 3),b = Test(value3 = 3)]
  </code></pre>
  
  <p>and</p>
  
  <pre><code>array3 = [c = Test(value3 = 4)]
  </code></pre>