title: Sorting an docs by comparing the docs in a subcollection with the most recent date in firestore
body: <p>I have a firestore structure like this:</p>
  <pre><code>chats &gt; chat docs with unique IDs
  </code></pre>
  <p>Each chat doc contains these values:</p>
  <pre><code>id, members and more info on the chat like nicknames etc.
  </code></pre>
  <p>In addition, there is a subcollection containing all the messages,</p>
  <pre><code>the messages also each have their own doc id, a date, and message.
  </code></pre>
  <p>How can I sort the chat docs when fetching them from firebase based on the last message thst was sent given each message has a timestamp associated with it.</p>
  <pre><code>Is it possible to solve this without modifying the firestore structure?
  </code></pre>