Display the list of my products in descending order in ionic 4

Hello everyone please I need your help, I would like to display the list of my products in descending order in ionic 4 but I can’t do it.
thank you for your help!

just make reverse to your array of products

let products = [...//some data]
products.reverse();

And don’t forget to sort first, before you reverse, or use a sort function to reverse sort in 1 go

Look at array sort javascript examples. Google is your best friend

1 Like

Hello everyone I found the results thank you very much for your help;
here is the result:
products: Product = ;
productSubject = new Subject<Nature>();

emitProduct() { {
this.productSubject.next(this.products.reverse());
}

Hello everyone I found the results thank you very much for your help;
here is the result:
products: Product = ;
productSubject = new Subject<Nature>();

emitProduct() { {
this.productSubject.next(this.products.reverse());
};

1 Like

Good job.
Consider using BehaviorSubject so your subscribers will get the latest submitted value once subscribed (instead of waiting to get something)
Tom

1 Like