code: private boolean sortActivitiesIfNeeded() {
          if (mActivitySorter != null && mIntent != null
                  && !mActivities.isEmpty() && !mHistoricalRecords.isEmpty()) {
              mActivitySorter.sort(mIntent, mActivities,
                      Collections.unmodifiableList(mHistoricalRecords));
              return true;
          }
          return false;
      }
docs: Sorts the activities if necessary which is if there is a
  sorter, there are some activities to sort, and there is some
  historical data.
  
  @return Whether sorting was performed.