Список Содержит метод sort, который сортирует список в алфавитном порядке (от a до z).
Я создал для вас функцию, чтобы сделать процесс более понятным:
List<String> sort(List<String> _myBranchListName){ // This function take List of strings and return it organized alphabetically
// List<String> _myBranchListName = ["B branch", "C branch" , "A branch"]; // example of input
print(_myBranchListName); // will show the result in the run log
_myBranchListName.sort();
print(_myBranchListName); // will show the result in the run log
return _myBranchListName;
}
Технически, вам нужно только _myBranchListName.sort()
для сортировки массива.