compare method

  1. @override
int compare(
  1. P a,
  2. P b
)
override

Compare two P properties returned by the mapper.

Implementation

@override
int compare(P a, P b) {
  final aIndex = order.indexOf(a);
  if (aIndex == -1) {
    throw StateError(
      'Cannot sort value "$a". Add it to the order list first.',
    );
  }

  final bIndex = order.indexOf(b);
  if (bIndex == -1) {
    throw StateError(
      'Cannot sort value "$b". Add it to the order list first.',
    );
  }

  return aIndex.compareTo(bIndex);
}