the leaderboards are sorted like this:
1000 * levels beaten - total time (all in seconds)
and you want the highest score possible.
therefore if you take more than 1000 seconds on a level your score will go down.
Close, but not quite.
Global is (levels completed * 1 million) - (total time * 1000)
That number determines your rank. The higher, the better. Reason for its "weird" math is to remove decimal points to total time which brings the total time up into the millions; therefore the levels completed math had to be brought in into the millions as well.
Also note, that warp zones add 5 seconds per stage to your total time. 12 warp levels in 5 chapters brings the possible second total to 300. You can remove a vast majority of this 300 (but not all as I will explain in a second) by simply beating the stages again and they won't disappear UNLESS you improve a time on any level. No, turning the game off and reopening it does not work, nor does simply clearing a level even if it's not an improvement. Further note, character warps do NOT act the same way as regular warps. Instead of dropping down to 0.000 in the save data upon clear, they will only decrease IF you are lower than 5 seconds on clearing them. Therefore something like Commander Video can go from 5 second entries to 3 second entries if ran real fast. But levels like The Kid cannot cause a reduced time if you are trying to get the most time squeezed out of your save. Just like other warps, they will go back to 5 seconds upon improving another time.