Output stackbrew library file in a canonical order

* Current LTS & weekly
* Previous LTS (descending order)
* Previous weekly (descending order)
diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh
index 3a3c36a..108f29e 100755
--- a/generate-stackbrew-library.sh
+++ b/generate-stackbrew-library.sh
@@ -1,4 +1,4 @@
-#!/usr/local/Cellar/bash/4.3.30/bin/bash
+#!/bin/bash
 set -e
 
 declare -A aliases
@@ -9,17 +9,39 @@
 
 versions=( */ )
 versions=( "${versions[@]%/}" )
+versions=( $(IFS=$'\n'; sort -Vr <<< "${versions[*]}") )
 url='git://github.com/cloudbees/jenkins-ci.org-docker'
 
 echo '# maintainer: Nicolas De Loof <nicolas.deloof@gmail.com> (@ndeloof)'
 echo '# maintainer: Michael Neale <mneale@cloudbees.com> (@michaelneale)'
 
 echo
-for version in "${versions[@]}"; do
-	commit="$(git log -1 --format='format:%H' -- "$version")"
-	versionAliases=( $version ${aliases[$version]} )
-	
-	for va in "${versionAliases[@]}"; do
+echo "# group: Current Releases"
+for current in $(IFS=$'\n'; sort -V <<< "${!aliases[*]}"); do
+	commit="$(git log -1 --format='format:%H' -- "$current")"
+	for va in "$current" ${aliases[$current]}; do
 		echo "$va: ${url}@${commit} $version"
 	done
+	echo
+done
+
+echo "# group: Previous LTS Releases"
+for version in "${versions[@]}"; do
+	if [[ "${aliases[$version]}" || "$version" != *.*.* ]]; then
+		continue
+	fi
+
+	commit="$(git log -1 --format='format:%H' -- "$version")"
+	echo "$version: ${url}@${commit} $version"
+done
+echo
+
+echo "# group: Previous Weekly Releases"
+for version in "${versions[@]}"; do
+	if [[ "${aliases[$version]}" || "$version" == *.*.* ]]; then
+		continue
+	fi
+
+	commit="$(git log -1 --format='format:%H' -- "$version")"
+	echo "$version: ${url}@${commit} $version"
 done