Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect scoring with greater than 9 results #71

Open
clintocarpenter opened this issue May 6, 2024 · 1 comment
Open

Incorrect scoring with greater than 9 results #71

clintocarpenter opened this issue May 6, 2024 · 1 comment

Comments

@clintocarpenter
Copy link

The issue is that the .sort() in the argsort function will by default use a string conversion so "11" sorts ahead of "9". I found this when trying to run

elo.getNewRatings([1688,1590,1581,1582,1550,1500,1465,1455,1435,1453,1432,1472,1526], [1,2,3,4,5,6,7,8,9,10,11,11,12]);

It fails the validation since there is not a zero score and no tie for last place. If you sort the results by numeric values it all works correctly.

basically just need

export const argsort = (arr: number[]) =>
  arr
    .map((element, index) => decor(element, index))
    .sort((a, b) => (a[0] - b[0]))
    .map((element) => undecor(element));

If you want to give me ability to create a branch/PR I'd be happy to put that change up for you.

@clintocarpenter
Copy link
Author

created PR for you to look at from our fork. It seems to do the trick for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant