compareTo method
override
    Compares this object to another object.
Returns a value like a Comparator when comparing this to other.
That is, it returns a negative integer if this is ordered before other,
a positive integer if this is ordered after other,
and zero if this and other are ordered together.
The other argument must be a value that is comparable to this object.
Implementation
@override
int compareTo(Chat other, [UserId? me]) {
  if (ongoingCall != null && other.ongoingCall == null) {
    return -1;
  } else if (ongoingCall == null && other.ongoingCall != null) {
    return 1;
  } else if (ongoingCall != null && other.ongoingCall != null) {
    final result = ongoingCall!.at.compareTo(other.ongoingCall!.at);
    return result == 0 ? id.compareTo(other.id) : result;
  }
  if (favoritePosition != null && other.favoritePosition == null) {
    return -1;
  } else if (favoritePosition == null && other.favoritePosition != null) {
    return 1;
  } else if (favoritePosition != null && other.favoritePosition != null) {
    final result = other.favoritePosition!.compareTo(favoritePosition!);
    return result == 0 ? id.compareTo(other.id) : result;
  }
  if (id.isLocalWith(me) && !other.id.isLocalWith(me)) {
    return 1;
  } else if (!id.isLocalWith(me) && other.id.isLocalWith(me)) {
    return -1;
  }
  final result = other.updatedAt.compareTo(updatedAt);
  return result == 0 ? id.compareTo(other.id) : result;
}