In which order are the gateways in rx_metadata stored?

For my application, I want to log the signal strengths of one LoRa node for different gateways. I have managed to log the data for a single gateway. Now, I would like to expand to multiple gateways.

I have following approach in mind:

gateway0=messageDecoded["uplink_message"]["rx_metadata"][0]["gateway_ids"]["gateway_id"]
rssi0=messageDecoded["uplink_message"]["rx_metadata"][0]["rssi"]
snr0=messageDecoded["uplink_message"]["rx_metadata"][0]["snr"]
gateway1=messageDecoded["uplink_message"]["rx_metadata"][1]["gateway_ids"]["gateway_id"]
rssi1=messageDecoded["uplink_message"]["rx_metadata"][1]["rssi"]
snr1=messageDecoded["uplink_message"]["rx_metadata"][1]["snr"]
gateway2=messageDecoded["uplink_message"]["rx_metadata"][2]["gateway_ids"]["gateway_id"]
rssi2=messageDecoded["uplink_message"]["rx_metadata"][2]["rssi"]
snr2=messageDecoded["uplink_message"]["rx_metadata"][2]["snr"]
sf=messageDecoded["uplink_message"]["settings"]["data_rate"]["lora"]["spreading_factor"]

However, in this case, it would be good for me to know how TTN orders the gateways: I think it is by the time the gateway was added but I’m not sure. Could someone comment on this please?

Hard coding the count, interesting, why not “For Each”??

I don’t think anyone would know - I store the one or more gateways and then analyse the data and thus far in three years that’s never related to the order they are presented - location, signal strength etc sure.

I doubt the LNS has time to mess about with sorting gateways, it’s enough to do already but you could read the source code and see.