26 lines
615 B
C#
26 lines
615 B
C#
namespace MeetTheTeacher.Model.Comparison;
|
|
|
|
/// <summary>
|
|
/// Compares <see cref="Teacher"/> instances by their room, sorting in ascending order
|
|
/// </summary>
|
|
/// <inheritdoc cref="IComparer{Teacher}"/>
|
|
public sealed class ByRoomComparer : IComparer<Teacher>
|
|
{
|
|
public int Compare(Teacher? x, Teacher? y)
|
|
{
|
|
if (x == null && y == null)
|
|
{
|
|
return 0;
|
|
}
|
|
if (x == null)
|
|
{
|
|
return 1;
|
|
}
|
|
if (y == null)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
return string.Compare(x!.Room, y!.Room, StringComparison.Ordinal);
|
|
}
|
|
}
|