You can create a sort function like below and after you get the site id array , you can call this method on that array .
var siteIds= [112,110,109,108,107,105]
siteIds.sort((a,b) =>a-b);
In your code :
item.siteIDs = [];
(this.subscriptionData || []).forEach((subscription, key) => {
subscription.sites.filter((obj: any) => {
if (obj.addressId == item.entityId && !item.siteIDs.includes(obj.siteId)) {
item.siteIDs.push(obj.siteId);
}
});
item.siteIDs.sort((a,b) => a-b);
I have a Site ID’s Array at present it is displayed as
112
110
109
108
107
105
But i want to display it in Ascending order please help
105
107
108
109
110
112
the typescript is like this
item.siteIDs = [];
(this.subscriptionData || []).forEach((subscription, key) => {
subscription.sites.filter((obj: any) => {
if (obj.addressId == item.entityId && !item.siteIDs.includes(obj.siteId)) {
item.siteIDs.push(obj.siteId);
}
});
html like this
<td class="col-md-1">
<div *ngFor="let siteId of item.siteIDs">
{{ siteId }}
</div>
</td>
No sir, can you modify the typescript code i wrote and provide me a solution please
It is type : it should be item.siteIDs instead of item.sideIDs .I updated the answer