</div>
<ul class="list-group">
- <a class="list-group-item" ng-repeat="version in data | orderBy"
+ <a class="list-group-item" ng-repeat="version in data | orderBy:versionOrder:true"
href="./{{version}}/index.html">
- {{version}}
+ {{normalizeVersion(version)}}
</a>
</ul>
</article>
.controller('docVersions', function ($scope, $http) {
$scope.loading = true;
+ $scope.normalizeVersion = function(v) {
+ return v.replace(/^v/, '');
+ };
+
+ $scope.versionOrder = function(v) {
+ if (v === 'master') { return Infinity; }
+ if (v === 'current') { return Number.MAX_VALUE; }
+
+ return $scope.normalizeVersion(v)
+ .split('.')
+ .reverse()
+ .reduce(function(acc, val, index) {
+ return acc + (val * Math.pow(100, index));
+ }, 0);
+ }
+
$http.get('./versions.json')
.success(function (data) {
$scope.data = data;