feat: sort by title name in level selection

This commit is contained in:
Orangerot 2025-01-08 03:14:51 +01:00
parent 9c229b94d0
commit 947570755e

View file

@ -135,7 +135,7 @@ class _LevelSelectionState extends State<LevelSelection> {
final directory = Directory(directoryPath); final directory = Directory(directoryPath);
try { try {
// List all files and folders in the directory // List all files and folders in the directory
return directory List<Simfile> simfiles = directory
.listSync() .listSync()
.where((entity) => FileSystemEntity.isDirectorySync(entity.path)) .where((entity) => FileSystemEntity.isDirectorySync(entity.path))
.map((entity) { .map((entity) {
@ -143,6 +143,9 @@ class _LevelSelectionState extends State<LevelSelection> {
simfile.load(); simfile.load();
return simfile; return simfile;
}).toList(); }).toList();
simfiles.sort((a,b) => a.tags['TITLE']!.compareTo(b.tags['TITLE']!));
return simfiles;
} catch (e) { } catch (e) {
print("Error reading directory: $e"); print("Error reading directory: $e");
return []; return [];