title: Group list values by KeyValuePair
body: <p>Say i have a list</p>
  
  <pre><code>[1,2,2,1,3,3,3,2,3,3,1,3,3,2,3]
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/tghx6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tghx6.png" alt="enter image description here"></a></p>
  
  <p>Any ideas how to group them (<code>List&lt;KeyValuePair&lt;int, int&gt;&gt;</code>) so that the key is the next smallest digit, and Value is next biggest digit, and if it repeats itself, group it with the same smallest key, if that makes sense...</p>
  
  <p>This is the output that I am looking for:</p>
  
  <pre><code>[Key, Value]
  [0,1]
  [0,2]
  [3,4]
  [3,5]
  [3,6]
  [7,8]
  [7,9]
  [10,11]
  [10,12]
  [13,14]
  </code></pre>