Skip to content

Commit

Permalink
Added the new sort array file
Browse files Browse the repository at this point in the history
Signed-off-by: 1000TurquoisePogs <[email protected]>
  • Loading branch information
1000TurquoisePogs committed Mar 31, 2020
1 parent 009ea57 commit 5b29839
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: "sortBy"
})
export class SortArray implements PipeTransform {
transform(array: any[], attribute: string): any[] {
array.sort((a: any, b: any) => {
if (a[attribute] < b[attribute]) {
return -1;
} else if (a[attribute] > b[attribute]) {
return 1;
} else {
return 0;
}
});
return array;
}
}

0 comments on commit 5b29839

Please sign in to comment.