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

Fix sorting of resources with numbers (numberish) titles #6426

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

turisap
Copy link

@turisap turisap commented Jun 30, 2021

Hi,

I have encountered a possible bug. The bug is when we pass to <FullCalender /> react component (timeline view) resources
with titles as numbers or numberish strings like { title: 2 } or { title: '2' }.

Resolves #6427

My best guess is that in this case the last if statement in the flexibleCompare function gets executed. The problem is that String.localeCompare returns wrong values, f.e the following example returns 1

const a = '6'; 
const b = '12'; 
console.log(a.localeCompare(b));

but this return -1:

const a = '1'; 
const b = '12';  
console.log(a.localeCompare(b));

However, they should return the same value for sorting to work as expected.

You can find a runnable demo in this repo.

There is also a codesandbox with reduced example.

It looks like this:

Screenshot 2021-06-30 at 16 08 17

It also can be solved by providing {numeric: true} as config param to localeCompare, but I am not sure which locale to pass in this case.

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

Successfully merging this pull request may close these issues.

Display resources in numerical order
2 participants