How is the display order of Skills defined?

Been trying to wrap my head around the logic, but how is the order Skills are displayed in the Menu and in Battle defined?
Is there any way we have control over in which order they should show up?
I believe they are sorted by IDs. At least this is my case.
looking at the source code it appears to be either by ID or by order added.
Pretty sure I tested this in the past and sadly it goes by order added.

I had wanted to have a skill "upgrade" in the middle of combat, but unlearning that skill and learning its "upgrade" makes it appear at the end of the list of skills, thus confusing the player. :\

I believe you could bypass this by just unlearning all skills and then having the character learn them in the order you want them to appear.

Ain't pretty, but it'll work and the player will never know.
It seems order added works as long as their ID's follow the same order.
I'm assuming this will apply to Items, Weapons and Armor too. Kind of a pain if you introduce new things later that should show up earlier in the list... ah well.

Thanks for the help guys.

Original thread: https://forums.rpgmakerweb.com/threads/how-is-the-display-order-of-skills-defined.74542/