Add presubmit hook for hidden API lists.

Check that they're sorted as expected and contain no duplicates.
The sort order now uses:
$ LC_COLLATE=C sort -f

So that non-alphanumeric characters are not ignored, giving a more
intuitive sort order. the '-f' means ignore case.

Also sort the existing lists accordingly.

Test: repo upload
Bug: 64382372
Merged-In: I52b884da33a9a46455df6747a215683d9d3c3218
Change-Id: Icc124fd8ceb3f001a9c11bbf40e0a111910c6b39
(cherry picked from commit e5dc64d4281dd9f38c2b585202e26ae4278fcfc5)
diff --git a/tools/hiddenapi/sort_api.sh b/tools/hiddenapi/sort_api.sh
new file mode 100755
index 0000000..1c6eb1b
--- /dev/null
+++ b/tools/hiddenapi/sort_api.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -e
+if [ -z "$1" ]; then
+  source_list=/dev/stdin
+  dest_list=/dev/stdout
+else
+  source_list="$1"
+  dest_list="$1"
+fi
+# Load the file
+readarray A < "$source_list"
+# Sort
+IFS=$'\n'
+A=( $(LC_COLLATE=C sort -f <<< "${A[*]}") )
+A=( $(uniq <<< "${A[*]}") )
+unset IFS
+# Dump array back into the file
+printf '%s\n' "${A[@]}" > "$dest_list"