title: android: Sort List after Adding items to the existing list using RecyclerView.Adapter
body: <p>I have a RecyclerView which shows list of items sorted in descending order that works fine when I initially launch the screen, but when I add some more items to the existing list and setting it to the adapter with notifyDataSetChanged() method the existing list gets sorted in ascending order and the new items get added at the bottom of the view.</p>
  
  <p>below is adapter</p>
  
  <pre><code> public class RecycleAdapter extends RecyclerView.Adapter&lt;RecycleAdapter.ViewHolder&gt; {
      private List&lt;Cinema&gt; lists;
      private int savedItems;
  
      public RecycleAdapter(List&lt;Cinema&gt; cinemas, int savedItems) {
          this.lists = cinemas;
          this.savedItems = savedItems;
      }
  
      public class ViewHolder extends RecyclerView.ViewHolder {
          public TextView cinemaTitle;
          public TextView cinemaDescription;
          public TextView cinemaDate;
          public LinearLayout newLayout;
  
          public ViewHolder(View view) {
              super(view);
              cinemaTitle = (TextView) view.findViewById(R.id.cinema_title);
              cinemaDescription = (TextView) view.findViewById(R.id.description_text);
              cinemaDate = (TextView) view.findViewById(R.id.cinema_date);
              newLayout = (LinearLayout) view.findViewById(R.id.new_cinema_layout);
          }
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemView = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.item_cinema, parent, false);
          return new ViewHolder(itemView);
      }
  
      @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
          Cinema cinema = cinemas.get(position);
          if (cinema.getId() &gt; savedItems) {
              holder.newLayout.setVisibility(View.VISIBLE);
          } else {
              holder.newLayout.setVisibility(View.INVISIBLE);
          }
  
          String title = cinema.getMessage().trim();
          String description = cinema.getDescription().trim();
          String date = cinema.getPublishedDate().trim();
          holder.cinemaTitle.setText(title);
          holder.cinemaDescription.setText(description);
          holder.cinemaDate.setText(date);
      }
  
      public void setCineams(List&lt;Cinema&gt; cinemas) {
          this.cinemas = cinemas;
          notifyDataSetChanged();
      }
  
      @Override
      public int getItemCount() {
          return cinemas.size();
      }
  }
  </code></pre>
  
  <p>and the method which updates the list from Fragment is given below:</p>
  
  <pre><code>    @Override
      public void onCinemaUpdated() {
      cinemas = firebaseHelper.getAllCinemas();
      //Method which sorts the lists in descending order after adding new items into it
      sortCinemas();
      if (recycleAdapterAdapter != null) {
          recycleAdapterAdapter.setCineams(cinemas);
      }
  }
  </code></pre>
  
  <p>I am not sure why am I getting this behaviour. Can anyone clarify on this?</p>