title: Sort ArrayList of objects with "pinned" objects at top behaves differently each execution
body: <p>So I am trying to display a list of groups in a recyclerview in Android.
  The groups are custom objects (Group) with a small amount of values, stored in a public static Arraylist (allGroups).</p>
  <p>I have a method to sort these groups by their &quot;time&quot; value, which is the time in milliseconds.</p>
  <p>Method to sort:</p>
  <pre><code>public static ArrayList&lt;Group&gt; sort(ArrayList&lt;Group&gt; list) {
      list.sort(Comparator.comparing(Group::getTime));
      Collections.reverse(list);
  
      ArrayList&lt;Group&gt; newSort = new ArrayList&lt;&gt;();
  
      for(Group g: list) {
          if(g.isPinned()) {
              newSort.add(g);
          }
      }
  
      for(Group g: list) {
          if(!g.isPinned()) {
              newSort.add(g);
          }
      }
  
      list.clear();
  
      return newSort;
  }
  </code></pre>
  <p>When I run the app the first time, it works fine and sorts my groups perfectly by pin and date, but whenever I add a group using the method below, it ONLY sorts it by date</p>
  <pre><code>        allGroups.add(new Group(
                  new BigInteger(130, new java.util.Random()).toString(32),
                  &quot;PB&quot;,
                  (long) (Math.random() * 1649157582577L),
                  new BigInteger(260, new java.util.Random()).toString(32)
          ).makePinned(false));
          allGroups = sort(allGroups);
          groupsAdapter.notifyDataSetChanged();
  </code></pre>
  <p>I have no clue what might be causing this, it makes no sense to me.</p>
  <p>Edit:</p>
  <p>Implementation for makePinned:</p>
  <pre><code>public Group makePinned(boolean pinned) {
      this.pinned = pinned;
      return this;
  }
  </code></pre>
  <p>Constructor of Group:</p>
  <pre><code>public Group(String name, String logo, long time, String message) {
      this.id = groupAmount + 1;
      this.name = name;
      this.logo = logo;
      this.time = time;
      this.message = message;
  }
  </code></pre>