Skip to content

Instantly share code, notes, and snippets.

@philipszdavido
Created September 18, 2017 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipszdavido/5b1861683669a526798207d668ad37fe to your computer and use it in GitHub Desktop.
Save philipszdavido/5b1861683669a526798207d668ad37fe to your computer and use it in GitHub Desktop.
//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