 'use strict';

/**
 * @ngdoc filter
 * @name SubSnoopApp.filter:sortnum
 * @function
 * @description
 * # sortnum
 * Filter in the SubSnoopApp.
 */
angular.module('SubSnoopApp')
  .filter('sortNum', ['$filter', function ($filter) {
    return function (num1, num2, a, b, reverse, secondary) {
      var val1, val2;

      if (!(secondary)) {
        secondary = 'alpha';
      }

      if (reverse) {
        val1 = 1;
        val2 = -1;
      } else {
        val1 = -1;
        val2 = 1;
      }

      if (num1 < num2) { return val1; }
      else if (num1 > num2) { return val2; }
      else {
        if (secondary === 'alpha') {
          if (typeof a !== 'string' && typeof b !== 'string') {
            a = a.subreddit;
            b = b.subreddit;
          }
          return $filter('sortAlpha')(a, b);
        }
        else if (secondary === 'date') {
          num1 = moment(a.created_utc*1000);
          num2 = moment(b.created_utc*1000);
          return sort(num1, num2, a, b, true, 'alpha');
        }
      }
    };
  }]);
@@ -226,26 +226,31 @@
 lter) %7B%0A
+%0A
     
-return
+var sort =
  functio
@@ -250,17 +250,16 @@
 function
- 
 (num1, n
@@ -1022,24 +1022,149 @@
   %7D%0A      %7D%0A
+    %7D%0A%0A    return function (num1, num2, a, b, reverse, secondary) %7B%0A      return sort(num1, num2, a, b, reverse, secondary);%0A
     %7D;%0A  %7D%5D)

Fix recursive call for sortNum filter