Ingress version is 2.83.1, Android 11, OnePlus 7T, Wi-Fi. As you can see, keys should be ordered by distance, but they are not.
Were you moving when you opened your key inventory?
Keys order is set on opening the inventory, and updates only on some actions like opening the associate portal from the key, changing the sort order…
But distance is updated in real time from your location.
If the keys are not in the same area, and you were moving toward the ones that are at 17.4 km but farther from the 17.5 one, it could explain the thing.
With the rounding that is done on distance for display purposes, just a movement of tens or a hundred of meters could be enough.
But if you can reproduce it from a fixed location even when closing the inventory or restarting the game, then it's a bug.
I wasn't moving, but some location drift might have happened, so your explanation would work.