title: Sort asynchronously with external source
body: <p>I want to sort my Github Repos by Clones in Typescript<br />
  The equivalence in plain js would be</p>
  <pre class="lang-js prettyprint-override"><code>repos.sort(async (a, b) =&gt; {
    (await insights.traffic.clones(user, b.name, username, password)).uniques -
      (await insights.traffic.clones(user, a.name, username, password)).uniques;
  });
  </code></pre>
  <p>But <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort" rel="nofollow noreferrer">Array.prototype.sort()</a> doesn't work with async/await</p>
  <p><code>repos</code> is <a href="https://docs.github.com/en/rest/reference/repos#list-repositories-for-a-user" rel="nofollow noreferrer"><code>https://api.github.com/users/&lt;user&gt;/repos</code></a><br />
  <code>insights</code> is <a href="https://www.npmjs.com/package/github-insights" rel="nofollow noreferrer"><code>import * as insights from 'github-insights'</code></a> <a href="https://kaaax0815.github.io/github-insights/classes/api.traffic.html#clones" rel="nofollow noreferrer">Docs for clones</a></p>
  <p>This would sort the repos in descending order be unique clones</p>
  <p>It would get every repo for my account and then sort it with <a href="https://docs.github.com/en/rest/reference/repos#get-repository-clones" rel="nofollow noreferrer"><code>https://api.github.com/repos/&lt;user&gt;/&lt;repo&gt;/traffic/clones</code></a></p>
  <p>Is there any way to make it work?</p>
  <p>Using <a href="https://www.npmjs.com/package/fast-sort" rel="nofollow noreferrer">fast-sort</a><br />
  I came up with this</p>
  <pre class="lang-js prettyprint-override"><code>const sorted = sort(repos).desc([
    async (u) =&gt; await (await insights.traffic.clones(user, u.name, username, password)).uniques
  ]);
  </code></pre>
  <p>but this doesn't sort at all, it just is <code>repos</code></p>