title: All 2 element combinations of arrays that follow a rule
body: <p>I have been studying algorithms and optimization and I got stuck on the following challenge and I'm seeking some guidance on how to solve this.</p>
  <p>Given 2 desc ordered distinct arrays of <code>N</code> and <code>M</code> sizes <code>(N&gt;M)</code>, write a function that returns an array with all possible 2 element (x, y) combinations of both array that follow the rule: if <code>x1 &gt; x2</code> then <code>y1 &gt; y2</code></p>
  <p>Example:</p>
  <pre><code>Input:
  
  A = [4,3,2,1]
  B = [20,10]
  
  
  Output:
  [
    [(4,20), (3,10)],
    [(4,20), (2,10)],
    [(4,20), (1,10)],
    [(3,20), (2,10)],
    [(3,20), (1,10)],
    [(2,20), (1,10)]
  ]
  </code></pre>
  <p>I'm doing this function in Java but I'd appreciate answers in any programming languages.</p>