From 5e55f4d9b881fe9769b7c72fbf1b4f33b98e4a20 Mon Sep 17 00:00:00 2001
From: Lars Trieloff <trieloff@adobe.com>
Date: Fri, 5 Jan 2018 12:55:47 +0000
Subject: [PATCH] sort properties in table of contents alphabetically #28

---
 examples/docs/arrays.schema.md        |  8 ++++----
 examples/docs/complex.schema.md       |  6 +++---
 examples/docs/custom.schema.md        |  2 +-
 examples/docs/deepextending.schema.md |  2 +-
 examples/docs/example.schema.md       |  2 +-
 examples/docs/examples.schema.md      |  2 +-
 examples/docs/extending.schema.md     |  2 +-
 examples/docs/simpletypes.schema.md   | 20 ++++++++++----------
 templates/md/properties.ejs           |  8 +++++---
 9 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/examples/docs/arrays.schema.md b/examples/docs/arrays.schema.md
index 82a53f0..2b9a7ea 100644
--- a/examples/docs/arrays.schema.md
+++ b/examples/docs/arrays.schema.md
@@ -19,13 +19,13 @@ This is an example schema with examples for multiple array types and their const
 
 | Property | Type | Required | Defined by |
 |----------|------|----------|------------|
+| [boollist](#boollist) | `boolean[]` | Optional | Arrays (this schema) |
+| [coordinatelist](#coordinatelist) | `number[][]` | Optional | Arrays (this schema) |
+| [intlist](#intlist) | `integer[]` | Optional | Arrays (this schema) |
 | [list](#list) | `string[]` | Optional | Arrays (this schema) |
 | [listlist](#listlist) | `array[]` | Optional | Arrays (this schema) |
-| [stringlistlist](#stringlistlist) | `string[][]` | Optional | Arrays (this schema) |
-| [intlist](#intlist) | `integer[]` | Optional | Arrays (this schema) |
-| [boollist](#boollist) | `boolean[]` | Optional | Arrays (this schema) |
 | [numlist](#numlist) | `number[]` | Optional | Arrays (this schema) |
-| [coordinatelist](#coordinatelist) | `number[][]` | Optional | Arrays (this schema) |
+| [stringlistlist](#stringlistlist) | `string[][]` | Optional | Arrays (this schema) |
 
 ## list
 
diff --git a/examples/docs/complex.schema.md b/examples/docs/complex.schema.md
index 9c2ab3b..a472fee 100644
--- a/examples/docs/complex.schema.md
+++ b/examples/docs/complex.schema.md
@@ -25,11 +25,11 @@ This is an example schema that uses types defined in other schemas.
 
 | Property | Type | Required | Defined by |
 |----------|------|----------|------------|
+| [and](#and) | complex | Optional | Complex References  (this schema) |
+| [or](#or) | complex | Optional | Complex References  (this schema) |
 | [refabstract](#refabstract) | complex | **Required** | Complex References  (this schema) |
-| [refnamed](#refnamed) | Simple | Optional | Complex References  (this schema) |
 | [reflist](#reflist) | Simple | Optional | Complex References  (this schema) |
-| [or](#or) | complex | Optional | Complex References  (this schema) |
-| [and](#and) | complex | Optional | Complex References  (this schema) |
+| [refnamed](#refnamed) | Simple | Optional | Complex References  (this schema) |
 | [xor](#xor) | complex | Optional | Complex References  (this schema) |
 
 ## refabstract
diff --git a/examples/docs/custom.schema.md b/examples/docs/custom.schema.md
index f6f7b4b..bfcdfc2 100644
--- a/examples/docs/custom.schema.md
+++ b/examples/docs/custom.schema.md
@@ -19,8 +19,8 @@ This is an extensible schema. It has `definitions`, that can be used in other sc
 
 | Property | Type | Required | Defined by |
 |----------|------|----------|------------|
-| [foo](#foo) | `string` | Optional | Custom (this schema) |
 | [bar](#bar) | `string` | Optional | Custom (this schema) |
+| [foo](#foo) | `string` | Optional | Custom (this schema) |
 
 ## foo
 
diff --git a/examples/docs/deepextending.schema.md b/examples/docs/deepextending.schema.md
index ab3f4bd..cf4a22c 100644
--- a/examples/docs/deepextending.schema.md
+++ b/examples/docs/deepextending.schema.md
@@ -27,9 +27,9 @@ This is an extending schema. It is extending another extending schema. It pulls
 | Property | Type | Required | Defined by |
 |----------|------|----------|------------|
 | [bar](#bar) | `string` | Optional | [Extensible](extensible.schema.md#bar) |
-| [id](#id) | `string` | Optional | [Definitions](definitions.schema.md#id) |
 | [baz](#baz) | `string` | Optional | [Extending](extending.schema.md#baz) |
 | [hey](#hey) | `string` | Optional | Deeply Extending (this schema) |
+| [id](#id) | `string` | Optional | [Definitions](definitions.schema.md#id) |
 
 ## bar
 
diff --git a/examples/docs/example.schema.md b/examples/docs/example.schema.md
index 5385085..606cf64 100644
--- a/examples/docs/example.schema.md
+++ b/examples/docs/example.schema.md
@@ -27,8 +27,8 @@ This is an example schema with examples. Too many examples? There can never be t
 
 | Property | Type | Required | Defined by |
 |----------|------|----------|------------|
-| [foo](#foo) | `string` | Optional | Example (this schema) |
 | [bar](#bar) | `string` | Optional | Example (this schema) |
+| [foo](#foo) | `string` | Optional | Example (this schema) |
 
 ## foo
 
diff --git a/examples/docs/examples.schema.md b/examples/docs/examples.schema.md
index 9b44b8d..d1fc319 100644
--- a/examples/docs/examples.schema.md
+++ b/examples/docs/examples.schema.md
@@ -36,8 +36,8 @@ This is an example schema with *multiple* examples. Too many examples? There can
 
 | Property | Type | Required | Defined by |
 |----------|------|----------|------------|
-| [foo](#foo) | `string` | Optional | Examples (this schema) |
 | [bar](#bar) | `string` | **Required** | Examples (this schema) |
+| [foo](#foo) | `string` | Optional | Examples (this schema) |
 
 ## foo
 
diff --git a/examples/docs/extending.schema.md b/examples/docs/extending.schema.md
index bc33bde..e7ce068 100644
--- a/examples/docs/extending.schema.md
+++ b/examples/docs/extending.schema.md
@@ -26,8 +26,8 @@ This is an extending schema. It pulls `definitions` from other schemas.
 | Property | Type | Required | Defined by |
 |----------|------|----------|------------|
 | [bar](#bar) | `string` | Optional | [Extensible](extensible.schema.md#bar) |
-| [id](#id) | `string` | Optional | [Definitions](definitions.schema.md#id) |
 | [baz](#baz) | `string` | Optional | Extending (this schema) |
+| [id](#id) | `string` | Optional | [Definitions](definitions.schema.md#id) |
 
 ## bar
 
diff --git a/examples/docs/simpletypes.schema.md b/examples/docs/simpletypes.schema.md
index f395b04..37f8deb 100644
--- a/examples/docs/simpletypes.schema.md
+++ b/examples/docs/simpletypes.schema.md
@@ -19,22 +19,22 @@ This is an example schema with examples for multiple types and their constraints
 
 | Property | Type | Required | Defined by |
 |----------|------|----------|------------|
-| [string_unconstrained](#string_unconstrained) | `string` | Optional | Simple Types (this schema) |
-| [string_length](#string_length) | `string` | Optional | Simple Types (this schema) |
-| [string_pattern](#string_pattern) | `string` | Optional | Simple Types (this schema) |
-| [string_pattern_noexample](#string_pattern_noexample) | `string` | Optional | Simple Types (this schema) |
-| [string_pattern_singleexample](#string_pattern_singleexample) | `string` | Optional | Simple Types (this schema) |
+| [integer_threes](#integer_threes) | `integer` | Optional | Simple Types (this schema) |
+| [interger_constrained](#interger_constrained) | `integer` | Optional | Simple Types (this schema) |
+| [interger_unconstrained](#interger_unconstrained) | `integer` | Optional | Simple Types (this schema) |
+| [number_constrained](#number_constrained) | `number` | Optional | Simple Types (this schema) |
+| [number_unconstrained](#number_unconstrained) | `number` | Optional | Simple Types (this schema) |
 | [string_date](#string_date) | `string` | Optional | Simple Types (this schema) |
 | [string_email](#string_email) | `string` | Optional | Simple Types (this schema) |
 | [string_hostname](#string_hostname) | `string` | Optional | Simple Types (this schema) |
 | [string_ipv4](#string_ipv4) | `string` | Optional | Simple Types (this schema) |
 | [string_ipv6](#string_ipv6) | `string` | Optional | Simple Types (this schema) |
+| [string_length](#string_length) | `string` | Optional | Simple Types (this schema) |
+| [string_pattern](#string_pattern) | `string` | Optional | Simple Types (this schema) |
+| [string_pattern_noexample](#string_pattern_noexample) | `string` | Optional | Simple Types (this schema) |
+| [string_pattern_singleexample](#string_pattern_singleexample) | `string` | Optional | Simple Types (this schema) |
+| [string_unconstrained](#string_unconstrained) | `string` | Optional | Simple Types (this schema) |
 | [string_uri](#string_uri) | `string` | Optional | Simple Types (this schema) |
-| [number_unconstrained](#number_unconstrained) | `number` | Optional | Simple Types (this schema) |
-| [interger_unconstrained](#interger_unconstrained) | `integer` | Optional | Simple Types (this schema) |
-| [interger_constrained](#interger_constrained) | `integer` | Optional | Simple Types (this schema) |
-| [number_constrained](#number_constrained) | `number` | Optional | Simple Types (this schema) |
-| [integer_threes](#integer_threes) | `integer` | Optional | Simple Types (this schema) |
 | [yesno](#yesno) | `boolean` | **Required** | Simple Types (this schema) |
 
 ## string_unconstrained
diff --git a/templates/md/properties.ejs b/templates/md/properties.ejs
index 3bd039a..e976efa 100644
--- a/templates/md/properties.ejs
+++ b/templates/md/properties.ejs
@@ -7,9 +7,11 @@
 # <%=title %> Properties
 
 
-
 | Property | Type | Required | Defined by |
 |----------|------|----------|------------|
-<%  _.forIn(props, (schema, property, object) => { %>
+<% _.keys(props).sort().forEach(property => {
+  const schema = props[property]; %>
 | [<%= property %>](#<%= property %>) | <%= schema.simpletype %> | <%= schema.required === true ? "**Required**" : "Optional" %> | <% if (schema.$oSchema) { %>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= property %>)<% } else { %><%= title %> (this schema)<% } %> |
-<% }); %>
\ No newline at end of file
+<%
+});
+%>
\ No newline at end of file
-- 
GitLab