NavigableSet
The NavigableSet, and its predecessor, SortedSet, define a contract for a distinct (no duplicates allowed) collection of objects maintained in a certain order.
The TreeSet class bundled with Java implements this interface. For concurrency, or for very large collections, use ConcurrentSkipListSet.
You said:
'Appointment' objects which have the following attributes: 'patient' 'date' 'type'
record Appointment ( String patient , LocalDate date , String type ) {}
Define a Comparator to control the sorting. We pass a method reference to access the member field by which we want to sort. In our example that is the LocalDate field named date.
Comparator < Appointment > comparator = Comparator.comparing( Appointment :: date );
Track our appointments. Specify the comparator to use automatically as elements added to this set.
NavigableSet < Appointment > appointments = new TreeSet <>( comparator );
Sample data.
appointments.addAll(
List.of(
new Appointment( "Alice" , LocalDate.of( 2025 , Month.APRIL , 23 ) , "trim" ) ,
new Appointment( "Bob" , LocalDate.of( 2025 , Month.JANUARY , 23 ) , "dye" ) ,
new Appointment( "Carol" , LocalDate.of( 2025 , Month.MARCH , 23 ) , "set" )
)
);
Add another element.
appointments.add(
new Appointment( "Davis" , LocalDate.of( 2025 , Month.FEBRUARY , 23 ) , "cut" )
);
See results.
System.out.println( "appointments = " + appointments );
appointments = [Appointment[patient=Bob, date=2025-01-23, type=dye], Appointment[patient=Davis, date=2025-02-23, type=cut], Appointment[patient=Carol, date=2025-03-23, type=set], Appointment[patient=Alice, date=2025-04-23, type=trim]]
Sure enough, the Appointment objects are kept in sorted order, arranged by the date.
You might want a secondary sort, to order any multiple appointments for the same date.
Comparator < Appointment > comparator =
Comparator
.comparing( Appointment :: date )
.thenComparing( Appointment :: patient );
Sequenced collections
In Java 21+, we have sequenced collections, adding more interfaces to the Java Collections Framework. These interfaces include:
NavigableSet, SortedSet, TreeSet, and ConcurrentSkipListSet all extend/implement those two new interfaces.
SequencedCollection < Appointment > appointments = new TreeSet <>( comparator );

SortedSetmakes the most sense.