sortPackages method
Sort the packages using some comparison method, or by the default manner, which is to put the application package first, followed by every other package in case-insensitive alphabetical order.
Implementation
void sortPackages([int compare(String a, String b)?]) {
packages.sort(compare ??
(String a, String b) {
// Based on how LicenseRegistry currently behaves, the first package
// returned is the end user application license. This should be
// presented first in the list. So here we make sure that first package
// remains at the front regardless of alphabetical sorting.
if (a == firstPackage) {
return -1;
}
if (b == firstPackage) {
return 1;
}
return a.toLowerCase().compareTo(b.toLowerCase());
});
}