У меня есть этот массив, и я хочу напечатать вопросы в текстовой метке по порядку. Есть ли функция, в которой он может прочитать идентификатор каждого вопроса и отсортировать его по порядку?
Это мой код:
struct Question {
let question: String
let id: Int
let answers: [ Answer ]
}
struct Answer {
let id: String
let answer: String
let isSelected: Bool
}
struct allQuestions {
let Questions = [
Question(question: "The easiest way to learn is:", id: 1, answers: [
Answer(id: "V", answer: "By viewing, reading, and observing how the others carry out certain tasks", isSelected: false),
Answer(id: "A", answer: "By listening, discussing and doing according to verbal instructions" , isSelected: false),
Answer(id: "K", answer: "By dping and experimenting by myself", isSelected: false)
]),