The ranking on the leaderboard is organized in two ways:
First, individuals who have completed the most tasks are always going to be at the top, because they have completed more of the quest.
Second, individuals who have completed the same number of tasks are ordered by the total amount of accumulated time it took them to finish those tasks. Remember, the clock stops between tasks, so this is the time that it has taken them to complete each task, along with any time-based hint penalties that may have accrued.
For example, if Sarah has completed 6 tasks in 30 total minutes and John has completed 4 tasks in 20 minutes, Sarah will rank higher on the board because she has completed more tasks.
Another example, Craig and Steve both completed 6 tasks. Craig finished in 3 hours and 30 minutes, but in doing so chose to sacrifice time (instead of coins) to buy a hint, which made his total time 4 hours and 30 minutes. Steve finished his tasks in 4 hours, but incurred no time penalties. Steve would be higher on the leaderboard than Craig.
Please note that the time that is displayed for a user will always reflect their total time for that task, including any penalties accrued.