Please help me. I can not use the pipe to do a sort on my list


I need to sort a list in descending order.


I have a tutorial that explains why filter and orderBy pipes aren’t available in Angular 2, and how you can go about filtering your data instead:

In short, modify your data with JS and display that in the template.


Hi @joshmorony .

So it’s that these data are in an array, I just wish that in * ngfor would already load in descending order.



export class AgendaPage {

players: any;
modifiedData: any;

constructor(public navCtrl: NavController, public navParams: NavParams) {

this.players = [
      "firstName": "Morgan",
      "lastName": "Benton",
      "username": "mbenton",
      "age": "10",
      "teamId": 1
      "firstName": "Kelsey",
      "lastName": "Banks",
      "username": "kbanks",
      "age": "5",
      "teamId": 2
      "firstName": "Jessica",
      "lastName": "Martinez",
      "username": "jmartinez",
      "age": "1",
      "teamId": 3
      "firstName": "Maggie",
      "lastName": "Walker",
      "username": "mwalker",
      "age": "10",
      "teamId": 4





There is no built-in option to do this (and for good reason), you will need to sort the array in agenda.ts.


How do This, Please @joshmorony

Show me With Example Below ::

Please, Leave a short of code here. with this function


I need to modify this function to put order list automatic


    return this.items.filter((item) => {
        return item.title.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1;



You will want to use a sort rather than a filter, see here for an example:

How you implement it will depend on what you want to sort by. You can find more in-depth documentation here:


Thank You So much.

But this is in .JS Not Angular2

Sorry I´m very confused =/!

Show one example in Angular / Ionic2 Please



Please, show me one example inside Ionic2 in list


homes = [
“h_id”: “3”,
“city”: “Dallas”,
“state”: “TX”,
“zip”: “75201”,
“price”: “162500”
}, {
“h_id”: “4”,
“city”: “Bevery Hills”,
“state”: “CA”,
“zip”: “90210”,
“price”: “319250”
}, {
“h_id”: “5”,
“city”: “New York”,
“state”: “NY”,
“zip”: “00010”,
“price”: “962500”

Please. Show me Here How do this in Sort By price DESC


Angular 2 / Ionic 2 use TypeScript, which is a superset of JavaScript, so you can still just use normal JavaScript in your code.

In that example, you would do something like this:

homes.sort((a, b) => {
    return parseFloat(b.price) - parseFloat(a.price);

In your case, you would just call whatever sort function you need to use after initially defining your array in the constructor, i.e:

this.players = [

this.players.sort((a,b) => {
    return whatever;




Neste caso o que estou fazendo aqui esta certo ??


this.eventData.getEventList().on(‘value’, snapshot => {
let rawList = [];

  snapshot.forEach( snap => {
      id: snap.key,
      nome: snap.val().nome,
      descricao: snap.val().descricao,
      local: snap.val().local,
      data_evento: snap.val().data_evento,
      banner: snap.val().banner,
      tipo: snap.val().tipo,

   this.eventList = rawList;
  // console.log(this.eventList);



ionViewDidLoad() {

this.eventList.sort((a,b) => {
// return whatever;
  return  parseFloat( - parseFloat(;





Descrição: {{event?.descricao}}

Local: {{event?.local}}

Data: {{event?.data_evento}}