Make player sort function work more better.
added test case
Merge pull request #565 from shans/oops

I hold this patch to be self-evident