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

@Pipe({
  name: 'sorttitle'
})                 
export class BooksSortPipe {
  transform(books) {            
    let byTitle = (book1, book2) => book1.title.localeCompare(book2.title);
    
    return books.slice().sort(byTitle);
  }
}