Order List not fix?

Hello everyone

Here is a problem with the order in which the info of an item-list is displayed

When I test on “ionic serve” this appears like this

]

But when I test on an iPhone 7, the order displays is not at all the same

                    this.http.get('BDD/Batiments.json')
                    .map(res => {
                        return res.json().filter((item) => {
                            return item.catID == this.idCategorie && Number(item.FirstLvlHDV) <= currentHDV;
                        })
                    })
                    .subscribe(dataBatiments => {

                        this.itemsDispo = dataBatiments;


                    });

My list displays the [key - title]

How can I fix my problem that the order is always the same, ie in order of key?

thank you in advance

sorry for my English

Kayl

Sort your array in your TypeScript file. Don’t rely on the asynchronous call to return items in the same order every time. Either insert items in order one at a time as they arrive, or sort the entire array once the call completes.

Would you have an example to offer me?

try this:

...

.subscribe(dataBatiments => {
  this.itemsDispo = dataBatiments;

  *** THIS ***
  this.itemsDispo.sort((itemA, itemB) => {
    return itemA.key - itemB.key;
  });
}

...