Created
September 18, 2017 17:44
-
-
Save philipszdavido/5b1861683669a526798207d668ad37fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//src/app/redux/sort.pipe.ts | |
import { Pipe, PipeTransform } from '@angular/core'; | |
import { Article } from './models/article'; | |
@Pipe({ | |
name: 'sort' | |
}) | |
export class SortPipe implements PipeTransform { | |
transform(articles: Article[], args?: any): Article[] { | |
return articles.sort((a: Article, b: Article)=> { | |
return b.points - a.points | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment