I am creating an application in Swift, and I am creating a section with a calendar where you will be able to see the list of users with a numeric data entered by them. These data are collected in a structure as follows:
struct User: Identifiable {
var id: String = UUID().uuidString
var name: String
var surname: String
var timetables: [String]
var toCheck: [String] {
return [name, surname]
}
}
User information is displayed like this:
ForEach(administratorManager.users) { user in
HStack {
VStack(alignment: .leading) {
Text(user.name).font(.subheadline)
Text(user.surname).font(.subheadline)
Text(user.orari[day]).font(.subheadline)
}
}
Spacer()
}
And they are displayed on the screen like this: Photo of the list displayed on the screen
The data is sorted according to their position in the database:

I'd like to sort the list by the number entered under the user's first and last name (the smallest above and so on). Anyone know how to fix?