compareVersions function
Orders two pub versions by their numeric major.minor.patch core, then by
the full text. Enough to say which of two locks is behind; not a semver
implementation.
Implementation
int compareVersions(String a, String b) {
List<int> core(String v) => [
for (final part in v.split(RegExp(r'[-+]')).first.split('.'))
int.tryParse(part) ?? 0,
];
final ca = core(a), cb = core(b);
for (var i = 0; i < 3; i++) {
final x = i < ca.length ? ca[i] : 0;
final y = i < cb.length ? cb[i] : 0;
if (x != y) return x.compareTo(y);
}
return a.compareTo(b);
}