+
+ private getSortedData(data: XMDeployableApp[]) {
+ if (!this.sort.active || this.sort.direction === '') {
+ return data;
+ }
+ return data.sort((a: XMDeployableApp, b: XMDeployableApp) => {
+ const isAsc = this.sort.direction === 'asc';
+ switch (this.sort.active) {
+ case 'name': return this.compare(a.name, b.name, isAsc);
+ case 'version': return this.compare(a.version, b.version, isAsc);
+ default: return 0;
+ }
+ });
+ }
+
+ private compare(a: any, b: any, isAsc: boolean) {
+ return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
+ }
+