From b9d41c01911b807cc557ad1ce2f58b691ec2483c Mon Sep 17 00:00:00 2001
From: Ralph Amissah <ralph.amissah@gmail.com>
Date: Sat, 1 Jun 2019 21:18:08 -0400
Subject: book index sort: Aa-Zz (replaces A-Za-z)

---
 org/meta_abstraction.org               | 22 ++++++++++++----------
 src/doc_reform/meta/metadoc_from_src.d | 22 ++++++++++++----------
 2 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org
index abfa404..3f5ba11 100644
--- a/org/meta_abstraction.org
+++ b/org/meta_abstraction.org
@@ -6724,10 +6724,9 @@ struct BookIndexReportSection {
   auto bookindex_write_section(BI)(
     BI bookindex_unordered_hashes
   ) {
-    debug(asserts) {
-      static assert(is(typeof(bookindex_unordered_hashes) == string[][string][string]));
-    }
-    auto mainkeys=bookindex_unordered_hashes.byKey.array.sort().release;
+    auto mainkeys =
+      bookindex_unordered_hashes.byKey.array
+      .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release;
     foreach (mainkey; mainkeys) {
       write("_0_1 !┨", mainkey, "┣! ");
       foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) {
@@ -6736,8 +6735,9 @@ struct BookIndexReportSection {
       }
       writeln(" \\\\");
       bookindex_unordered_hashes[mainkey].remove("_a");
-      auto subkeys
-        = bookindex_unordered_hashes[mainkey].byKey.array.sort().release;
+      auto subkeys =
+        bookindex_unordered_hashes[mainkey].byKey.array
+        .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release;
       foreach (subkey; subkeys) {
         write("  ", subkey, ", ");
         foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) {
@@ -6773,8 +6773,9 @@ struct BookIndexReportSection {
     int heading_lev_markup, heading_lev_collapsed;
     string attrib;
     int[string] indent;
-    auto mainkeys
-      = bookindex_unordered_hashes.byKey.array.sort().release;
+    auto mainkeys =
+      bookindex_unordered_hashes.byKey.array
+      .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release;
     ObjGenericComposite[] bookindex_section;
     ObjGenericComposite comp_obj_heading_, comp_obj_para;
     auto node_para_int_ = node_metadata_para_int;
@@ -6855,8 +6856,9 @@ struct BookIndexReportSection {
         }
         bi_tmp ~= " \\\\\n    ";
         bookindex_unordered_hashes[mainkey].remove("_a");
-        auto subkeys
-          = bookindex_unordered_hashes[mainkey].byKey.array.sort().release;
+        auto subkeys =
+          bookindex_unordered_hashes[mainkey].byKey.array
+          .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release;
         foreach (subkey; subkeys) {
           bi_tmp ~= subkey ~ ", ";
           buffer.clear();
diff --git a/src/doc_reform/meta/metadoc_from_src.d b/src/doc_reform/meta/metadoc_from_src.d
index c4c7365..3d6b441 100644
--- a/src/doc_reform/meta/metadoc_from_src.d
+++ b/src/doc_reform/meta/metadoc_from_src.d
@@ -5393,10 +5393,9 @@ template DocReformDocAbstraction() {
     auto bookindex_write_section(BI)(
       BI bookindex_unordered_hashes
     ) {
-      debug(asserts) {
-        static assert(is(typeof(bookindex_unordered_hashes) == string[][string][string]));
-      }
-      auto mainkeys=bookindex_unordered_hashes.byKey.array.sort().release;
+      auto mainkeys =
+        bookindex_unordered_hashes.byKey.array
+        .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release;
       foreach (mainkey; mainkeys) {
         write("_0_1 !┨", mainkey, "┣! ");
         foreach (ref_; bookindex_unordered_hashes[mainkey]["_a"]) {
@@ -5405,8 +5404,9 @@ template DocReformDocAbstraction() {
         }
         writeln(" \\\\");
         bookindex_unordered_hashes[mainkey].remove("_a");
-        auto subkeys
-          = bookindex_unordered_hashes[mainkey].byKey.array.sort().release;
+        auto subkeys =
+          bookindex_unordered_hashes[mainkey].byKey.array
+          .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release;
         foreach (subkey; subkeys) {
           write("  ", subkey, ", ");
           foreach (ref_; bookindex_unordered_hashes[mainkey][subkey]) {
@@ -5436,8 +5436,9 @@ template DocReformDocAbstraction() {
       int heading_lev_markup, heading_lev_collapsed;
       string attrib;
       int[string] indent;
-      auto mainkeys
-        = bookindex_unordered_hashes.byKey.array.sort().release;
+      auto mainkeys =
+        bookindex_unordered_hashes.byKey.array
+        .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release;
       ObjGenericComposite[] bookindex_section;
       ObjGenericComposite comp_obj_heading_, comp_obj_para;
       auto node_para_int_ = node_metadata_para_int;
@@ -5518,8 +5519,9 @@ template DocReformDocAbstraction() {
           }
           bi_tmp ~= " \\\\\n    ";
           bookindex_unordered_hashes[mainkey].remove("_a");
-          auto subkeys
-            = bookindex_unordered_hashes[mainkey].byKey.array.sort().release;
+          auto subkeys =
+            bookindex_unordered_hashes[mainkey].byKey.array
+            .sort!("toUpper(a) < toUpper(b)", SwapStrategy.stable).release;
           foreach (subkey; subkeys) {
             bi_tmp ~= subkey ~ ", ";
             buffer.clear();
-- 
cgit v1.2.3