У меня есть данные из бэкэнда, показывающие некоторые магазины, но я хочу показать их в алфавитном порядке в виде таблицы , как этот . Я попытался отсортировать весь список по первой букве имени, затем попытался сгруппировать их, но не смог.
Вот моя структура для магазина
struct Store: Codable {
let stores: [StoreElement]
}
// MARK: - StoreElement
struct StoreElement: Codable {
let id, name, floor, type: String
let storeDescription: StoreDescription
let logo: StoreLogo
enum CodingKeys: String, CodingKey {
case id = "_id"
case name, floor, type
case storeDescription = "description"
case logo
}
}
// MARK: - Logo
struct StoreLogo: Codable {
let filename: String
let size: Int
let mimetype, url: String
}
// MARK: - Description
struct StoreDescription: Codable {
let html, md: String
}