code: function comparator(a, b) {
      var aHasIndex = a.hasOwnProperty('index'),
          bHasIndex = b.hasOwnProperty('index');
  
      if (aHasIndex) {
        if (bHasIndex) {
          if (a.index != b.index) {
            return a.index - b.index;
          }
        }
        else {
          return -1;
        }
      }
  
      else if (bHasIndex) {
        return 1;
      }
  
      var aHasTimestamp = a.hasOwnProperty('timestamp'),
          bHasTimestamp = b.hasOwnProperty('timestamp');
  
      if (aHasTimestamp) {
        if (bHasTimestamp) {
          if (a.timestamp != b.timestamp) {
            return b.timestamp - a.timestamp;
          }
        }
        else {
          return -1;
        }
      }
  
      else if (bHasTimestamp) {
        return 1;
      }
      
      return a.name > b.name ? 1 : -1;
    }
docs: We want sort by index (lower index first), followed by date (most recent first), and finishing with an alphabetical name sort.