Help with turn order in CBS

Im creating a CBS and want to set the order of who attacks first, second, etc based on the agility points of the player/monsters, but I dont know how to do that. Can someone help me with that just giving some tips?
If it is like in Rm2k3, with "Charging Bar" you have to create an "event" that calculates the order each round:
Event Battle - Page1 (AutoStart):
Code:
<>Variable:[Turn Party-A] + Hero-A Agility
<>Variable:[Turn Party-B] + Hero-B Agility
<>Variable:[Turn Party-C] + Hero-C Agility
<>Variable:[Turn Party-D] + Hero-D Agility
<>Variable:[Turn Monster-A] + Variable:[Slime-Agility]
<>Variable:[Turn Monster-B] + Variable:[Slime-Agility]
<>Variable:[Turn Monster-C] + Variable:[Slime-Agility]
<>Variable:[Turn Monster-D] + Variable:[RedSlime-Agility]
<>IF [Turn Party-A] >= 1000
  <>Call Event: Hero-A - Page Event Menu
  <>
:End
<>IF [Turn Party-B] >= 1000
  <>Call Event: Hero-A - Page Event Menu
  <>
:End
<>IF [Turn Party-C] >= 1000
  <>Call Event: Hero-A - Page Event Menu
  <>
:End
<>IF [Turn Party-D] >= 1000
  <>Call Event: Hero-A - Page Event Menu
  <>
:End
<>IF [Turn Monster-A] >= 1000
  <>Call Event: Monster-A - Page Event Action
  <>
:End
<>IF [Turn Monster-B] >= 1000
  <>Call Event: Monster-B - Page Event Action
  <>
:End
<>IF [Turn Monster-C] >= 1000
  <>Call Event: Monster-C - Page Event Action
  <>
:End
<>IF [Turn Monster-D] >= 1000
  <>Call Event: Monster-D - Page Event Action
  <>
:End
<>

On page 1 of each enemy event or member, you must set the variable to zero at the end of the action, example:
Monster-A - Page 1 (Touch Event):
Code:
<>Variable:[Random] - 1..3
<>IF Variable:[Random] = 1
  <>Comment: Attack
  <>
:End
<>IF Variable:[Random] = 2
  <>Comment: Combo
  <>
:End
<>IF Variable:[Random] = 3
  <>Comment: Self-Destruction
  <>
:End
<>Variable:[Turn Monster-A] = 0
<>

Demo Sample:
https://tanatosmaker.forumeiros.com/t5-2k-2k3-advanced-cbs-v2-0
This system is old, sorry, I didn't have time to translate, it's in Portuguese.
Thx dude 😀

Original thread: https://forums.rpgmakerweb.com/threads/help-with-turn-order-in-cbs.113968/