I'm sorting the charge times(this is the fill percentage of the turn bars, the acceleration is how fast they fill to 100%). It's part of my process to figure out how to build a Turn Priority Window.
Result:
I can't figure out why sort puts element 2 in the middle when it's clearly not larger than element 3.
JavaScript:
function sortChargeTimeForAll() {
const allBattlers = $gameParty.members().concat($gameTroop.members());
let allChargeTime = allBattlers.map(battler => battler.tpbChargeTime());
return allChargeTime.sort((a, b) => a > b);
};
Result:
- 0: 0.28787919961617514
- 1: 0.27468077504089805
- 2: 0.03881201245200878 <--- this should go last
- 3: 0.1327129416040321
- 4: 0.10528425551945243
- 0: 1
- 1: 0.9456361500326629
- 2: 0.5839310813100546 <--- Same element
- 3: 0.6778320104620777
- 4: 0.6504033243774981
I can't figure out why sort puts element 2 in the middle when it's clearly not larger than element 3.