Sort by medals if two players have the same score
Fix issue with getRecords query

This fixes an issue in the getRecords query that was exposed when a
player registered a record with the same distance on several stages.