Class Sort
java.lang.Object
theLocalLoop.Sort
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 Summary
Modifier and TypeMethodDescriptionstatic 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.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.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.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.static voidsortByDateTime(LinkedList<Event> events) Sorts a list of events by their date and time in chronological order.static voidsortByDuration(LinkedList<Event> events) Sorts a list of events by their duration in ascending order.static voidsortByName(LinkedList<Event> events) Sorts a list of events by their names in alphabetical order.static voidsortByOrganizer(LinkedList<Event> events) Sorts a list of events by their organizers in alphabetical order.
-
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
Sorts a list of events by their names in alphabetical order.- Parameters:
events- Current list of events.
-
sortByDateTime
Sorts a list of events by their date and time in chronological order.- Parameters:
events- Current list of events.
-
sortByOrganizer
Sorts a list of events by their organizers in alphabetical order.- Parameters:
events- Current list of events.
-
sortByDuration
Sorts a list of events by their duration in ascending order.- Parameters:
events- Current list of events.
-
filterByType
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
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
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.
-