title: How do I sort two arrays in relation to each other?
body: <p>I prototype in python and I'm used the zip function for this, I'm not sure how to do this in Java.  Basically I have two lists (one is <code>names</code> and one is <code>data</code>) and want them sorted in relation to each other. My program only processes a list (<code>data</code>, in this case) but I use the <code>names</code> as a reference to what <code>data</code> I'm processing and I want to try to experiment with processing my data in a different order. Here's an example of the structure (in reality my data is not given to me stored but I would do either a basic sort or a reverse sort on it, nothing fancy).</p>
  <pre class="lang-java prettyprint-override"><code>String[] names = new String[]{&quot;Monkey1&quot;, &quot;Dog2&quot;, &quot;Horse3&quot;, &quot;Cow4&quot;, &quot;Spider5&quot;};
  int[] data = new int[]{1, 2, 3, 4, 5};
  </code></pre>
  <p>so the inverse would be</p>
  <pre><code>name = Spider5, Cow4, Horse3, Dog2, Monkey1
  data = 5, 4, 3, 2, 1
  </code></pre>
  <p>I found this question: <a href="https://stackoverflow.com/questions/2118932/is-there-an-accepted-java-equivalent-to-pythons-zip">Is there an accepted Java equivalent to Python's zip()</a>, but I would rather (if possible and for the faint of heart) do this using libraries I already have (Java commons, apache commons, etc).  If there's no other way then I'll give <code>functional java</code> a shot. Any suggestions?</p>