Check the word order of the dictionary file

Change-Id: I2903c5f5a6715425ed192844a869640f439f5eb5
diff --git a/Makefile b/Makefile
index 0cdbd72..79f2f4b 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@
 # name of python virtualenv that is used to run commands
 VENV_NAME      := venv-docs
 
-.PHONY: help test lint doc8 reload Makefile prep
+.PHONY: help test lint doc8 reload Makefile prep format format-dict
 
 # Put it first so that "make" without argument is like "make help".
 help: $(VENV_NAME)
@@ -34,7 +34,7 @@
   sphinx-reload $(SOURCEDIR)
 
 # lint and link verification. linkcheck is part of sphinx
-test: lint spelling linkcheck
+test: lint spelling linkcheck dict-check
 
 lint: doc8
 
@@ -43,6 +43,16 @@
   doc8 --max-line-length 119 \
   $$(find . -name \*.rst ! -path "*venv*" ! -path "*vendor*" ! -path "*repos*" )
 
+# Words in dict.txt must be in the correct alphabetical order and must not duplicated.
+dict-check: format-dict
+	@git update-index --refresh
+
+format: format-dict
+
+format-dict:
+	@cat dict.txt | sort -u > /tmp/sorted.txt
+	@mv /tmp/sorted.txt dict.txt
+
 license: $(VENV_NAME)
 	source $</bin/activate ; set -u ;\
   reuse --version ;\