Currently keys are sorted according to distance & name.
More sorting logic could be added based on how people actually use keys in the inventory view.
For now, I would suggest sort keys by energy percentage. This would be based on the total energy left in the deployed resos on that portal. This would be very useful for people maintaining important portals as currently you have to scroll quite a bit to do this.
Only 1 reso if deployed. But is 50% charged. That would make the portal 50% energy.
If 8 resos are deployed, and all are between 10-15% energy, the average % would be taken of the 8 resos to give a value between 10-15 %.