created dynamicSort function to sort player scores