Class Sort

java.lang.Object
theLocalLoop.Sort

public class Sort extends Object
The Sort class provides methods for sorting and filtering a list of events based on user choices. It includes methods for sorting by name, date and time, organizer, and duration, as well as filtering by type and organizer.
  • Method Details

    • sortAndFilter

      public static LinkedList<Event> sortAndFilter(LinkedList<Event> events, int sortChoice, int filterChoice, Scanner input)
      Sorts and filters a list of events based on user choices for sorting and filtering criteria.
      Parameters:
      events - Current list of events.
      sortChoice - User's choice for sorting criteria (1: Name, 2: Date and Time, 3: Organizer, 4: Duration).
      filterChoice - User's choice for filtering criteria (1: Type, 2: Organizer, 3: No filtering).
      input - Scanner object for user input.
      Returns:
      A new list of events with filtering and sorting choices applied.
    • sortByName

      public static void sortByName(LinkedList<Event> events)
      Sorts a list of events by their names in alphabetical order.
      Parameters:
      events - Current list of events.
    • sortByDateTime

      public static void sortByDateTime(LinkedList<Event> events)
      Sorts a list of events by their date and time in chronological order.
      Parameters:
      events - Current list of events.
    • sortByOrganizer

      public static void sortByOrganizer(LinkedList<Event> events)
      Sorts a list of events by their organizers in alphabetical order.
      Parameters:
      events - Current list of events.
    • sortByDuration

      public static void sortByDuration(LinkedList<Event> events)
      Sorts a list of events by their duration in ascending order.
      Parameters:
      events - Current list of events.
    • filterByType

      public static LinkedList<Event> filterByType(LinkedList<Event> events, String targetType)
      Filters a list of events by a specified type and returns a new list containing only the events that match the target type, ignoring case sensitivity.
      Parameters:
      events - Current list of events.
      targetType - The type to filter by, inputted by the user.
      Returns:
      A new list of events that match the target type.
    • filterByOrganizer

      public static LinkedList<Event> filterByOrganizer(LinkedList<Event> events, String targetOrganizer)
      Filters a list of events by a specified organizer and returns a new list containing only the events that match the target organizer, ignoring case sensitivity.
      Parameters:
      events - Current list of events.
      targetOrganizer - The organizer to filter by, inputted by the user.
      Returns:
      A new list of events that match the target organizer.
    • filterByFormat

      public static LinkedList<Event> filterByFormat(LinkedList<Event> events, String targetFormat)
      Filters a list of events by a specified format and returns a new list containing only the events that match the target format, ignoring case sensitivity.
      Parameters:
      events - Current list of events.
      targetFormat - The format to filter by, inputted by the user.
      Returns:
      A new list of events that match the target format.