<p dir="auto">Currently, Deno only sorts the imported and exported names from import and export specifiers. The goal is to also sort the import and export specifiers in a certain sort function.</p>
<p dir="auto">Usually, I sort those specifiers in Node in this way,</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import 'style.css' // might be side effects module if JS
import fs from 'fs' // default import
import * as path from 'path' // namespace import
import { ref } from 'vue' // normal named import

// typed imports
import type TypeC from 'abc'
import type * as TypeC from 'abc'
import type { TypeC } from 'abc'"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s">'style.css'</span> <span class="pl-c">// might be side effects module if JS</span>
<span class="pl-k">import</span> <span class="pl-s1">fs</span> <span class="pl-k">from</span> <span class="pl-s">'fs'</span> <span class="pl-c">// default import</span>
<span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">path</span> <span class="pl-k">from</span> <span class="pl-s">'path'</span> <span class="pl-c">// namespace import</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">ref</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'vue'</span> <span class="pl-c">// normal named import</span>

<span class="pl-c">// typed imports</span>
<span class="pl-k">import</span> <span class="pl-k">type</span> <span class="pl-smi">TypeC</span> <span class="pl-k">from</span> <span class="pl-s">'abc'</span>
<span class="pl-k">import</span> <span class="pl-k">type</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-smi">TypeC</span> <span class="pl-k">from</span> <span class="pl-s">'abc'</span>
<span class="pl-k">import</span> <span class="pl-k">type</span> <span class="pl-kos">{</span> <span class="pl-smi">TypeC</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'abc'</span></pre></div>
<p dir="auto">Exports are also sorted in that way as well.</p>
<p dir="auto">For Deno, I am thinking to sort like,</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import 'style.css' // might be side effects module if JS
import fs from 'fs' // default import
import * as path from 'path' // namespace import
import { ref } from 'vue' // normal named import

// url imports go into one section
import fs from 'https://deno.land/std/node/fs.ts'
/// ... the rest of imports

// typed imports
import type TypeC from 'abc'
import type * as TypeC from 'abc'
import type { TypeC } from 'abc'

// type imports from url here
import type { Colors } from 'https://deno.land/std/colors.ts'"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s">'style.css'</span> <span class="pl-c">// might be side effects module if JS</span>
<span class="pl-k">import</span> <span class="pl-s1">fs</span> <span class="pl-k">from</span> <span class="pl-s">'fs'</span> <span class="pl-c">// default import</span>
<span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">path</span> <span class="pl-k">from</span> <span class="pl-s">'path'</span> <span class="pl-c">// namespace import</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">ref</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'vue'</span> <span class="pl-c">// normal named import</span>

<span class="pl-c">// url imports go into one section</span>
<span class="pl-k">import</span> <span class="pl-s1">fs</span> <span class="pl-k">from</span> <span class="pl-s">'https://deno.land/std/node/fs.ts'</span>
<span class="pl-c">/// ... the rest of imports</span>

<span class="pl-c">// typed imports</span>
<span class="pl-k">import</span> <span class="pl-k">type</span> <span class="pl-smi">TypeC</span> <span class="pl-k">from</span> <span class="pl-s">'abc'</span>
<span class="pl-k">import</span> <span class="pl-k">type</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-smi">TypeC</span> <span class="pl-k">from</span> <span class="pl-s">'abc'</span>
<span class="pl-k">import</span> <span class="pl-k">type</span> <span class="pl-kos">{</span> <span class="pl-smi">TypeC</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'abc'</span>

<span class="pl-c">// type imports from url here</span>
<span class="pl-k">import</span> <span class="pl-k">type</span> <span class="pl-kos">{</span> <span class="pl-smi">Colors</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'https://deno.land/std/colors.ts'</span></pre></div>
<p dir="auto">I have checked that <code class="notranslate">dprint</code> can sort the import and export specifiers. But, Deno hasn't enabled them. I am not familiar with the code base, so I will let the core team decide the preferred way of sorting.</p>
<p dir="auto">Some unresolved questions are how should <code class="notranslate">deno fmt</code> handle side effect imports? Should they be left as it is and let the users sort (since they will become one section after other imports are sorted)?</p>
<p dir="auto">Thanks!</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { x, y } from &quot;./alphabet.ts&quot;
import { foo, bar } from &quot;std/foo/bar.ts&quot;
import { z } from &quot;./blah.ts&quot;"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">x</span><span class="pl-kos">,</span> <span class="pl-s1">y</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"./alphabet.ts"</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">foo</span><span class="pl-kos">,</span> <span class="pl-s1">bar</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"std/foo/bar.ts"</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">z</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"./blah.ts"</span></pre></div>
<p dir="auto">imo would look better as</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { x, y } from &quot;./alphabet.ts&quot;
import { z } from &quot;./blah.ts&quot;
import { foo, bar } from &quot;std/foo/bar.ts&quot;"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">x</span><span class="pl-kos">,</span> <span class="pl-s1">y</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"./alphabet.ts"</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">z</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"./blah.ts"</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">foo</span><span class="pl-kos">,</span> <span class="pl-s1">bar</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"std/foo/bar.ts"</span></pre></div>