compareValues static method

int compareValues(
  1. Object? a,
  2. Object? b
)

SQLite-ish ordering used for full composite-key ordering and for prefix matching by the planner. Public so executor code in other libraries can reuse it.

Implementation

static int compareValues(Object? a, Object? b) {
  int rank(Object? v) {
    if (v == null) return 0;
    if (v is num) return 1;
    if (v is String) return 2;
    return 3;
  }

  final ra = rank(a);
  final rb = rank(b);
  if (ra != rb) return ra.compareTo(rb);
  if (a == null) return 0;
  if (a is num && b is num) return a.compareTo(b);
  if (a is String && b is String) return a.compareTo(b);
  return a.toString().compareTo(b.toString());
}