Repository: pyexcel/pyexcel

Issue:
Book created from a dict discards ordering
[Since Python 3.7, dictionaries preserve order](https://docs.python.org/3/whatsnew/3.7.html), so I'd expect the following code to pass:

```python
book = pyexcel.Book(
    {
        "Stuff": [["some", "data", "I", "can't", "parse"]],
        "Records": [["record_id"], ["a"], ["b"], ["c"]],
        "Quarters": [
            ["id", "quarter"],
            ["one", "2021Q1"],
            ["two", "2021Q2"],
        ],
    }
)
assert list(book.sheet_names()) == ["Stuff", "Records", "Quarters"]
```

Unfortunately it does not.

```
E       AssertionError: assert ['Quarters', ...rds', 'Stuff'] == ['Stuff', 'Re...', 'Quarters']
E         At index 0 diff: 'Quarters' != 'Stuff'
E         Full diff:
E         - ['Stuff', 'Records', 'Quarters']
E         + ['Quarters', 'Records', 'Stuff']
```

I'd expect `sheet_names` to return the sheet names in the same order as the source dict.

Discussion:

Patch:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index bc376d7..8bf8a22 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,14 @@
 Change log
 ================================================================================
 
+0.6.4 - ???
+--------------------------------------------------------------------------------
+
+**fixed**
+
+#. `#219 <https://github.com/pyexcel/pyexcel/issues/219>`_: book created from
+   dict no longer discards order.
+
 0.6.3 - 01.08.2020
 --------------------------------------------------------------------------------
 
diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst
index 4dcd1db..c1f224c 100644
--- a/CONTRIBUTORS.rst
+++ b/CONTRIBUTORS.rst
@@ -1,4 +1,4 @@
-16 contributors
+17 contributors
 ================================================================================
 
 In alphabetical order:
@@ -8,6 +8,7 @@ In alphabetical order:
 * `Arunkumar Rajendran <https://github.com/arunkumar-ra>`_
 * `Ayan Banerjee <https://github.com/ayan-b>`_
 * `Chris Hill-Scott <https://github.com/quis>`_
+* `Craig Anderson <https://github.com/craiga>`_
 * `Daryl Yu <https://github.com/darylyu>`_
 * `J Harley <https://github.com/julzhk>`_
 * `Joel Nothman <https://github.com/jnothman>`_
diff --git a/pyexcel/book.py b/pyexcel/book.py
index ecae71f..e6128b1 100644
--- a/pyexcel/book.py
+++ b/pyexcel/book.py
@@ -56,10 +56,6 @@ class Book(BookMeta):
         if sheets is None:
             return
         keys = sheets.keys()
-        if not isinstance(sheets, compact.OrderedDict):
-            # if the end user does not care about the order
-            # we put alphatical order
-            keys = sorted(keys)
         for name in keys:
             value = sheets[name]
             if isinstance(value, Sheet):


Test patch:
diff --git a/tests/test_book.py b/tests/test_book.py
index c1a1d52..c644671 100644
--- a/tests/test_book.py
+++ b/tests/test_book.py
@@ -19,3 +19,12 @@ def test_book_len():
 
     book = p.Book(book_dict)
     eq_(len(book.test.array), 1)
+
+
+def test_sheet_ordering():
+    test_data = [["a", "b"]]
+
+    book_dict = {"first": test_data, "middle": test_data, "last": test_data}
+
+    book = p.Book(book_dict)
+    eq_(book.sheet_names(), ["first", "middle", "last"])