code: function tableDataSort(key, data, direction) {
      var dataCopy = data.map(function (i) { return Object.assign({}, i); });
      dataCopy.sort(function (a, b) {
          var sortResult;
          var aTmp = a[key];
          var bTmp = b[key];
          if (typeof aTmp === 'number' && typeof bTmp === 'number') {
              sortResult = sort(aTmp, bTmp);
          }
          else {
              sortResult = sort((aTmp + '').toLowerCase(), (bTmp + '').toLowerCase());
          }
          return sortResult * direction;
      });
      return dataCopy;
  }
docs: https://github.com/thelgevold/angular-2-samples