package com.google.sps.utilities;

import com.google.sps.data.Event;
import com.google.sps.data.User;
import com.google.sps.data.VolunteeringOpportunity;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class EventRanker {
  /**
   * Sorts events based on each event's score.
   * Breaks ties with the event's number of VolunteeringOpportunity
   * requiredSkills that match the user's skills.
   * 
   * @param user The user for whom the events are ranked
   * @param unrankedEvents A {@link Set} of events that need to be ranked
   * @return A {@link List} of events that is ranked according to
   * each element's score
   */
  public static List<Event> rankEvents(User user, Set<Event> unrankedEvents) {
    return new ArrayList<>();
  }

  private static int getEventScore(User user, Event event) {

  }
}

@@ -28,16 +28,55 @@
 ities;%0A%0A
+import com.google.common.collect.Sets;%0A
 import c
@@ -210,24 +210,83 @@
 .ArrayList;%0A
+import java.util.Collections;%0Aimport java.util.Comparator;%0A
 import java.
@@ -463,90 +463,125 @@
 t's 
-number of VolunteeringOpportunity%0A   * requiredSkills that match the user's skills
+date; the more recent event will be%0A   * ranked higher.%0A   * Makes the assumption that all events are NOT in the past
 .%0A  
@@ -900,32 +900,405 @@
     
-return new ArrayList%3C%3E()
+List%3CEvent%3E rankedEvents = new ArrayList%3C%3E(unrankedEvents);%0A    Collections.sort(rankedEvents,%0A        (Event event1, Event event2) -%3E %7B%0A          return getEventScore(user, event1).compareTo(getEventScore(user, event2));%0A        (Event event1, Event event2) -%3E %7B%0A          return event1.getDate().compareTo(event2.getDate());%0A    %7D);%0A    Collections.reverse(rankedEvents);%0A    return rankedEvents
 ;%0A  
@@ -1321,11 +1321,15 @@
 tic 
-i
+I
 nt
+eger
  get
@@ -1365,15 +1365,392 @@
 vent) %7B%0A
+    Set%3CString%3E interestsAndSkills = user.getInterests();%0A    interestsAndSkills.addAll(user.getSkills());%0A    Set%3CString%3E labelsAndSkills = event.getLabels();%0A    for (VolunteeringOpportunity opportunity : event.getOpportunities()) %7B%0A      labelsAndSkills.addAll(opportunity.getRequiredSkills());%0A    %7D%0A    return Sets.intersection(interestsAndSkills, labelsAndSkills).size();
 %0A  %7D%0A%7D%0A

Write algorithm for ranking