tag:crieit.net,2005:https://crieit.net/tags/%E8%BE%9E%E6%9B%B8%E9%A0%86%E8%A8%98%E6%95%B0%E6%B3%95/feed
「辞書順記数法」の記事 - Crieit
Crieitでタグ「辞書順記数法」に投稿された最近の記事
2022-07-24T00:55:00+09:00
https://crieit.net/tags/%E8%BE%9E%E6%9B%B8%E9%A0%86%E8%A8%98%E6%95%B0%E6%B3%95/feed
tag:crieit.net,2005:PublicArticle/18247
2022-07-18T00:02:40+09:00
2022-07-24T00:55:00+09:00
https://crieit.net/posts/Dictionary-Ordinal-Number-Notation
辞書順記数法 (Dictionary Ordinal Number Notation) を解説しようぜ(^~^)?
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 どのフォルダーに入ってるんだぜ?」</p>
<p><a href="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png?mw=700" alt="202101__character__28--kifuwarabe-futsu.png" /></a><br />
「 4番のフォルダーだぜ」</p>
<pre><code class="plaintext">📂 0
📂 1
📂 2
📂 3
📂 4
📂 5
📂 6
📂 7
📂 8
📂 9
📂 10
📂 11
📂 12
📂 13
...
</code></pre>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 👆 Windows のファイルエクスプローラーは 名前順にソートすると 数字は昇順に並ぶのか。<br />
よっしゃ Visual Studio 2022 Preview で開けたろ」</p>
<pre><code class="plaintext">📂 0
📂 1
📂 11
📂 12
📂 13
📂 14
📂 15
📂 16
📂 17
📂 18
📂 19
📂 2
📂 20
📂 21
📂 22
📂 23
📂 24
...
</code></pre>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 👆 4 のフォルダーはどこだぜ!」</p>
<p><a href="https://crieit.now.sh/upload_images/31f0f35be3a4b6b05ce597c7aab702b762dc10e82743b.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/31f0f35be3a4b6b05ce597c7aab702b762dc10e82743b.png?mw=700" alt="202108__character__12--ohkina-hiyoko-futsu2.png" /></a><br />
「 辞書順に並んでるから 多分 39 の下よ」</p>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 なんで ソートのアルゴリズムが違うんだぜ!」</p>
<p><a href="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png?mw=700" alt="202101__character__28--kifuwarabe-futsu.png" /></a><br />
「 嫌なら Windows を捨てて Linux にしろだぜ」</p>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 Windows の名前ソートを調べたろ」</p>
<h2 id="Windowsのファイルエクスプローラーの名前順"><a href="#Windows%E3%81%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%A8%E3%82%AF%E3%82%B9%E3%83%97%E3%83%AD%E3%83%BC%E3%83%A9%E3%83%BC%E3%81%AE%E5%90%8D%E5%89%8D%E9%A0%86">Windowsのファイルエクスプローラーの名前順</a></h2>
<pre><code class="plaintext">📂 0A # 0 が無視されるとしても A が数字より上なのが分けがわからん
📂 0
📂 1
📂 -1 # ハイフンは負数とは判定されない
📂 2
📂 3
📂 4
📂 5
📂 6
📂 7
📂 08 # 0 は無視される。数字順と思えば納得
📂 8
📂 9
📂 10
📂 99
📂 100
📂 A
</code></pre>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 👆 ワケ分かんね」</p>
<h2 id="Visual Studio 2022 Preview のソリューション エクスプローラーの名前順"><a href="#Visual+Studio+2022+Preview+%E3%81%AE%E3%82%BD%E3%83%AA%E3%83%A5%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3+%E3%82%A8%E3%82%AF%E3%82%B9%E3%83%97%E3%83%AD%E3%83%BC%E3%83%A9%E3%83%BC%E3%81%AE%E5%90%8D%E5%89%8D%E9%A0%86">Visual Studio 2022 Preview のソリューション エクスプローラーの名前順</a></h2>
<pre><code class="plaintext">📂 0
📂 08
📂 0A
📂 1
📂 -1 # ハイフンは負数とは判定されない
📂 10
📂 100
📂 2
📂 3
📂 4
📂 5
📂 6
📂 7
📂 8
📂 9
📂 99
📂 A
</code></pre>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 👆 納得の辞書順だぜ」</p>
<p><a href="https://crieit.now.sh/upload_images/31f0f35be3a4b6b05ce597c7aab702b762dc10e82743b.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/31f0f35be3a4b6b05ce597c7aab702b762dc10e82743b.png?mw=700" alt="202108__character__12--ohkina-hiyoko-futsu2.png" /></a><br />
「 辞書順の方が基本で、<br />
むしろ Windows ファイルエクスプローラーの方が気を利かせて 数字の部分を並び替えてくれるのよ。<br />
多分 電話番号とか 想定してんじゃないの?」</p>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 だれが 電話番号なんか想定してフォルダーを並び替えてほしいんだぜ!<br />
前ゼロを無視したり、負数の符号に対応してないのに 正の整数だけソートしたり、ワケ分からん!」</p>
<p><a href="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png?mw=700" alt="202101__character__28--kifuwarabe-futsu.png" /></a><br />
「 分けの分かる部分だけを使えだぜ」</p>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 わたしの手にかかれば 問題は 解決までの手順に変わるぜ」</p>
<h1 id="[解決方法] 零,または正の整数は昇順になる"><a href="#%5B%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%B3%95%5D+%E9%9B%B6%EF%BC%8C%E3%81%BE%E3%81%9F%E3%81%AF%E6%AD%A3%E3%81%AE%E6%95%B4%E6%95%B0%E3%81%AF%E6%98%87%E9%A0%86%E3%81%AB%E3%81%AA%E3%82%8B">[解決方法] 零,または正の整数は昇順になる</a></h1>
<h2 id="例"><a href="#%E4%BE%8B">例</a></h2>
<pre><code class="plaintext">📂 1
📂 2
📂 3
📂 4
📂 5
📂 6
📂 7
📂 8
📂 9
📂 A10
</code></pre>
<pre><code class="plaintext">📂 A91
📂 A92
📂 A93
📂 A94
📂 A95
📂 A96
📂 A97
📂 A98
📂 A99
📂 AA100
</code></pre>
<pre><code class="plaintext">📂 AA991
📂 AA992
📂 AA993
📂 AA994
📂 AA995
📂 AA996
📂 AA997
📂 AA998
📂 AA999
📂 AAA1000
</code></pre>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 👆 <code>前A</code> を付ければいいんだぜ」</p>
<p><a href="https://crieit.now.sh/upload_images/31f0f35be3a4b6b05ce597c7aab702b762dc10e82743b.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/31f0f35be3a4b6b05ce597c7aab702b762dc10e82743b.png?mw=700" alt="202108__character__12--ohkina-hiyoko-futsu2.png" /></a><br />
「 <code>前A</code> って何よ!」</p>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 <code>前ゼロ</code> の <code>A</code> 版だぜ」</p>
<h2 id="手順"><a href="#%E6%89%8B%E9%A0%86">手順</a></h2>
<p>👇 零,または正の整数があるとする</p>
<pre><code class="plaintext">0 1 21 321 4321
- - -- --- ----
</code></pre>
<p>👇 <code>桁数×2-1</code> の横幅があると考えてほしい</p>
<pre><code class="plaintext">0 1 21 321 4321
- - --- ----- -------
</code></pre>
<p>👇 <code>前A</code> で埋める</p>
<pre><code class="plaintext">0 1 A21 AA321 AAA4321
- - --- ----- -------
</code></pre>
<p>これで正の数は辞書順に並ぶ</p>
<h2 id="備考"><a href="#%E5%82%99%E8%80%83">備考</a></h2>
<ul>
<li>アスキーコードの順を考えると A(大文字) が好ましいが、 a(小文字) でも構わない</li>
</ul>
<p><a href="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png?mw=700" alt="202101__character__28--kifuwarabe-futsu.png" /></a><br />
「 負の数は どうすんだぜ?」</p>
<h1 id="[解決方法] 負の整数は昇順になる"><a href="#%5B%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%B3%95%5D+%E8%B2%A0%E3%81%AE%E6%95%B4%E6%95%B0%E3%81%AF%E6%98%87%E9%A0%86%E3%81%AB%E3%81%AA%E3%82%8B">[解決方法] 負の整数は昇順になる</a></h1>
<h2 id="例"><a href="#%E4%BE%8B">例</a></h2>
<p>👇 例: Windows ファイルエクスプローラーのファイル名,フォルダー名向け</p>
<pre><code class="plaintext">📂 ___900 # -100
📂 __01 # - 99
📂 __09 # - 91
📂 __10 # - 90
📂 __89 # - 11
📂 __90 # - 10
📂 _1 # - 9
📂 _2 # - 8
📂 _7 # - 3
📂 _8 # - 2
📂 _9 # - 1
📂 0 # Zero
</code></pre>
<p>👇 例: Visual Studio 2022 Preview のメソッド名の並び順向け</p>
<pre><code class="plaintext">add___900() # -100
add__01() # - 99
add__90() # - 10
add_1() # - 9
add_8() # - 2
add_9() # - 1
add0() # Zero
</code></pre>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 👆 <code>前_</code> を付けて ひっくり返った数を使えば 負数も昇順に並ぶぜ」</p>
<p><a href="https://crieit.now.sh/upload_images/31f0f35be3a4b6b05ce597c7aab702b762dc10e82743b.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/31f0f35be3a4b6b05ce597c7aab702b762dc10e82743b.png?mw=700" alt="202108__character__12--ohkina-hiyoko-futsu2.png" /></a><br />
「 <code>前_</code> とか <code>ひっくり返った数</code> って何よ!」</p>
<p><a href="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png?mw=700" alt="202101__character__28--kifuwarabe-futsu.png" /></a><br />
「 <code>ひっくり返った数</code> というのは、その数を1桁増やした数の絶対値の最小の数だな」</p>
<h2 id="手順"><a href="#%E6%89%8B%E9%A0%86">手順</a></h2>
<p>👇 負の整数があるとする</p>
<pre><code class="plaintext"> -1 -21 -321 -4321
-- --- ---- -----
</code></pre>
<p>👇 負の符号を除去する</p>
<pre><code class="plaintext"> 1 21 321 4321
- -- --- ----
</code></pre>
<p>👇 <code>桁数×2</code> の横幅があると考えてほしい</p>
<pre><code class="plaintext"> 1 21 321 4321
-- ---- ------ --------
</code></pre>
<p>👇 <code>その数を1桁増やした数の最小の数</code> を求め、上に置く</p>
<pre><code class="plaintext"> 10 100 1000 10000
1 21 321 4321
-- ---- ------ --------
</code></pre>
<p>👇 引き算をする</p>
<pre><code class="plaintext"> 10 100 1000 10000
- 1 - 21 - 321 - 4321
-- ---- ------ --------
9 79 679 5679
</code></pre>
<p>👇 差の横幅を <code>前_</code> で埋める</p>
<pre><code class="plaintext"> -- ---- ------ --------
_9 __79 ___679 ____5679
</code></pre>
<p>これが負数の表記だ。辞書順で昇順に並ぶ</p>
<h2 id="備考"><a href="#%E5%82%99%E8%80%83">備考</a></h2>
<ul>
<li>👆 アンダースコア <code>_</code> は使いたくなかった。 <code>0</code> が辞書順なら <code>0</code> にしたかったが、 Windows ファイルエクスプローラーや、 Visual Studio 2022 Preview のメソッドの並び順は <code>0</code> を無視するという 分けの分からない挙動なので仕方なく使用</li>
</ul>
<h1 id="-13 ~ 13 の例"><a href="#-13+%EF%BD%9E+13+%E3%81%AE%E4%BE%8B">-13 ~ 13 の例</a></h1>
<pre><code class="plaintext">📂 __87 # -13
📂 __88 # -12
📂 __89 # -11
📂 __90 # -10
📂 _1 # -9
📂 _2 # -8
📂 _3 # -7
📂 _4 # -6
📂 _5 # -5
📂 _6 # -4
📂 _7 # -3
📂 _8 # -2
📂 _9 # -1
📂 0
📂 1
📂 2
📂 3
📂 4
📂 5
📂 6
📂 7
📂 8
📂 9
📂 A10
📂 A11
📂 A12
📂 A13
</code></pre>
<p><a href="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/5b53e954894672b36c716412a272826b62dc0fea91b9c.png?mw=700" alt="202101__character__31--ramen-tabero-futsu2.png" /></a><br />
「 👆 これで楽になったぜ」</p>
<p><a href="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/e846bc7782a0e037a1665e6b3d51b02462dc100f04369.png?mw=700" alt="202101__character__28--kifuwarabe-futsu.png" /></a><br />
「 こんな おかしな <strong>バッドノウハウ</strong> が流行る前に GUIのリストのソートアルゴリズムを ユーザーが指定できるようにしてほしいぜ」</p>
<h1 id="関連する記事"><a href="#%E9%96%A2%E9%80%A3%E3%81%99%E3%82%8B%E8%A8%98%E4%BA%8B">関連する記事</a></h1>
<p>📖 <a target="_blank" rel="nofollow noopener" href="https://qiita.com/muzudho1/items/95852145eceddecd1503">Qiita版 辞書順記数法</a> - 頭が固い説明<br />
📖 <a href="https://crieit.net/posts/Beads-Nested-Number-Notation">数珠玉記数法</a> - 組み合わせて使える<br />
📖 <a href="https://crieit.net/posts/Cyber-Number-Notation">電脳記数法</a> - 辞書順記数法と 数珠玉記数法を組み合わせたもの</p>
<p>Example: 📖 <a target="_blank" rel="nofollow noopener" href="https://github.com/muzudho/dictionary-ordinal-number-notation">dictionary-ordinal-number-notation</a></p>
むずでょ