MV Sort Skills by ID

Hello!

Would someone be able to help me create a plugin to adjust an odd default behavior of how MV lists skills?

By default, the order in which skills are listed (such as in battle) has the skills listed by database ID order. However, if an actor gains access to a skill through an equipment, that skills will always be listed at the bottom of the list, regardless of it's database ID.

Ideally, I'd like all skills regardless of how they are learned to be listed by database ID.

Let me know if you have any questions.

Thank you!
I don't know about MV code, but this is written in MZ and I would assume the same in MV.
JavaScript:
Game_Actor.prototype.skills = function() {
    const list = [];
    for (const id of this._skills.concat(this.addedSkills())) {
        if (!list.includes($dataSkills[id])) {
            list.push($dataSkills[id]);
        }
    }
    return list;
};
Which makes sense why it behaves that way (the added skill from trait is added later to the list)
The solution should be as simple as just adding a sort function after that. Save this as a new plugin.
JavaScript:
(() => {
    actorSkills = Game_Actor.prototype.skills
    Game_Actor.prototype.skills = function(){
        return actorSkills.call(this).sort((a,b) => { return a.id - b.id })
    }
})()
I haven't tested it yet, but the solution shouldn't be too far from this.
I don't know about MV code, but this is written in MZ and I would assume the same in MV.
Tested it out in MV, and it seems to be working great! Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/sort-skills-by-id.142396/