title: SwiftUI List with sections using dictionary of array
body: <p>I have an array of users returned. I want to group them by created date and then display them in SwiftUI List with sections. The section title is the date. After I group the users I end up with a Dictionary of user arrays and the key is the date that group all users that have been created in the same date I want to use the key as a section and the value (user array) as List rows. It seems that List only works with array. Any clean solution to prepare the data for the List so it can display the sections and its content ?</p>
  <pre><code>import SwiftUI
  import Combine
  
  struct ContentView: View {
      @EnvironmentObject var interactor: Interactor
  
      var body: some View {
          List(interactor.users) { user in // Error: Cannot convert value of type '[String : [User]]' to expected argument type 'Range&lt;Int&gt;'
               
          }
          .onAppear {
              interactor.loadUsers()
          }
      }
  }
  
  
  class Interactor: ObservableObject {
      @Published private(set) var users = [String: [User]]()
  
      func loadUsers() {
          let allUsers = [User(id: &quot;1&quot;, name: &quot;Joe&quot;, createdAt: Date()),
                          User(id: &quot;2&quot;, name: &quot;Jak&quot;, createdAt: Date())]
  
          users = Dictionary(grouping: allUsers) { user in
              let dateFormatted = DateFormatter()
              dateFormatted.dateStyle = .short
              return dateFormatted.string(from: user.createdAt)
          }
      }
  }
  
  struct User: Identifiable {
      let id: String
      let name: String
      let createdAt: Date
  }
  
  </code></pre>