import 'package:collection/collection.dart'; import '../enumerations.dart'; import '../models/language.dart'; /// Compare two lists by their content ignoring their elements order. bool equalContent(List list1, List list2) { return const DeepCollectionEquality.unordered().equals(list1, list2); } /// Sort the given list of languages so that German appears first, /// English second, and all other languages follow in alphabetical order. List sortLanguageList(List langList) { List sortedLanguages = List.from(langList); sortedLanguages.sort((a, b) { // German first if (a.code == 'de') return -1; if (b.code == 'de') return 1; // English second if (a.code == 'en') return -1; if (b.code == 'en') return 1; // All others by name ascending return a.name.compareTo(b.name); }); return sortedLanguages; } /// Sort the given list of sectors of interest, placing [SectorOption.other] at the end. List sortSectorsList(List sectorList) { List sortedSectors = List.from(sectorList); sortedSectors.sort((a, b) { // other last if (a.name == 'other') return 1; if (b.name == 'other') return -1; // All others by name ascending return a.name.compareTo(b.name); }); return sortedSectors; }