title: libgdx setUserObject() not setting Object
body: <p>I need to resort a SnapShotArray so I may render my actors in the correct order.  Ordering should be an absolute distance from a center, though I want to hold on to sign for later in the rendering process to determine whether it put to the left or right of center.  I determined distance from center for each actor in the first for loop, and tried using setUserObject().  When I later tried to retrieve this in the sort Comparator I was told it was a null value.</p>
  <pre><code>SnapshotArray&lt;Actor&gt; children = getChildren();
      children.begin();
      int n = children.size;
      
      for (int i = getIndexOfFocus() + 1; i &lt; n; i++) {
          Actor child = children.get(i);
          int offset = i - Math.round(getIndexOfFocus());
          child.setUserObject(Integer.valueOf(offset));
      }
      //Arrays.sort(&lt;SnapShotArray&gt;children, 0, n, new MyElementComparator());
      children.sort(new MyElementComparator());  
  </code></pre>
  <p>Comparator class:</p>
  <pre><code>private static class MyElementComparator implements Comparator&lt;Actor&gt;{
         public int compare (Actor a1, Actor a2){
             Integer e1 = (Integer) a1.getUserObject();
             Integer e2 = (Integer) a2.getUserObject();
             System.out.println(&quot;1(&quot; + a1 + &quot;, &quot; + e1 + &quot;), 2(&quot; + a2 + &quot;, &quot; + e2 + &quot;)&quot;);
             int r = 0;
             if (Math.abs(e1) &lt; Math.abs(e2)) r = -1;
             if (Math.abs(e1) == Math.abs(e2)) r = 0;
             if (Math.abs(e1) &gt; Math.abs(e2)) r = 1;
             return r;
         }
      }
  </code></pre>
  <p>results of Sys out above:</p>
  <pre><code>    1(TextButton: index_1, null), 2(TextButton: index_0, null)
  </code></pre>