title: Quickest way to determine the longest consecutive value range in a 2D-Array
body: <p><strong>The problem</strong></p>
  
  <p>let's assume we're working with a large dataset and for the sake of simplicity we use this smaller one in this question:</p>
  
  <pre><code>dataset = [["PLANT", 4,11],
             ["PLANT", 4,12],
             ["PLANT", 34,4],
             ["PLANT", 6,5],
             ["PLANT", 54,45],
             ["ANIMAL", 5,76],
             ["ANIMAL", 7,33],
             ["Animal", 11,1]]
  </code></pre>
  
  <p>and we want to find out which column has the longest range of consecutive values, what would be the fastest way to find out, which is the best column? </p>
  
  <p><strong>The naive approach</strong></p>
  
  <p>I found out it quickly can be sorted by each column with</p>
  
  <pre><code>sortedDatasets = []
  for i in range(1,len(dataset[0]):
      sortedDatasets.append(sorted(dataset,key=lambda x: x[i]))
  </code></pre>
  
  <p>But here comes the laggy part: we could go on from here and do a <code>for loop</code> for each of the sorted datasets, and count the consecutive elements but when it comes to processing <code>for loops</code> python is very slow.</p>
  
  <p><strong>Now my the question</strong>: is there a faster way than this naive approach, is there maybe even an built-in function for these 2D-containers?</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>More precisely the meaning of a range can be described by this pseudo algorithm - this includes incrementing if <code>current value == next value</code>: </p>
  
  <pre><code>if nextValue &gt; current Value +1: 
       {reset counter} 
  else: 
       {increment counter}
  </code></pre>