Hello,
I hope all of you are fine and doing well,
I need a Pipe that sort Array1 by id using OrderArray.
HTML = " <ng-container *ngFor="let item of items | sortBy : ‘id’>
Array1:
[{“id”: 1,“title”: “Post-1”,“thumb”: “post1.png”},
{“id”: 2,“title”: “Post-2”,“thumb”: “post2.png”},
{“id”: 3,“title”: “Post-3”,“thumb”: “post3.png”},
{“id”: 4,“title”: “Post-4”,“thumb”: “post4.png”},
{“id”: 5,“title”: “Post-5”,“thumb”: “post5.png”}]
OrderArray:
[3, 5, 2, 4, 1]
I need the result to be:
Result:
[{“id”: 3,“title”: “Post-3”,“thumb”: “post3.png”},
{“id”: 5,“title”: “Post-5”,“thumb”: “post5.png”},
{“id”: 2,“title”: “Post-2”,“thumb”: “post2.png”},
{“id”: 4,“title”: “Post-4”,“thumb”: “post4.png”},
{“id”: 1,“title”: “Post-1”,“thumb”: “post1.png”},]
Hope I’ll find someone to help, I tried a lot without success.
Thanks