diff --git a/gulpfile.js b/gulpfile.js index 1e1fefa..1751640 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -319,6 +319,35 @@ } }, { + name: "sortbylast", + func: function (obj, key) { + return obj.sort(function(a,b){ + var a, b; + if (typeof a[key] === 'string') { + a = a[key].split(' '); + a = a[a.length - 1]; + a.toUpperCase(); + } else { + a[key]; + } + if (typeof b[key] === 'string') { + b = b[key].split(' '); + b = b[b.length - 1]; + b.toUpperCase(); + } else { + b[key]; + } + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + }); + } + }, + { name: "startswith", func: function (string, match) { return string.startsWith(match); @@ -501,6 +530,35 @@ } }, { + name: "sortbylast", + func: function (obj, key) { + return obj.sort(function(a,b){ + var a, b; + if (typeof a[key] === 'string') { + a = a[key].split(' '); + a = a[a.length - 1]; + a.toUpperCase(); + } else { + a[key]; + } + if (typeof b[key] === 'string') { + b = b[key].split(' '); + b = b[b.length - 1]; + b.toUpperCase(); + } else { + b[key]; + } + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + }); + } + }, + { name: "startswith", func: function (string, match) { return string.startsWith(match); @@ -575,6 +633,35 @@ } }, { + name: "sortbylast", + func: function (obj, key) { + return obj.sort(function(a,b){ + var a, b; + if (typeof a[key] === 'string') { + a = a[key].split(' '); + a = a[a.length - 1]; + a.toUpperCase(); + } else { + a[key]; + } + if (typeof b[key] === 'string') { + b = b[key].split(' '); + b = b[b.length - 1]; + b.toUpperCase(); + } else { + b[key]; + } + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + }); + } + }, + { name: "startswith", func: function (string, match) { return string.startsWith(match);