import 'package:collection/collection.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; }