I've found an unexpected(?) change that stems from #2391.
<Hello name="John" Number="2" />
With {ignoreCase: false}, which according to the docs should take case into account when sorting the props, the above example now expects name to be sorted before Number.
I know _why_ it sorts the way it does: #2391 switched to using String#localeCompare, which does…
> 'name'.localeCompare('Number')
-1
Looking at the lib/rules/jsx-sort-props.js code, I'm not sure what changes would be required to accommodate both this issue and #2381, unfortunately.
So, the crux of this issue is: is this an unexpected change, or should I alter my expectations and update the documentation to reflect this behavior?
This definitely seems like an unexpected change.
Specifically, we should probably only use localeCompare when ignoreCase is true?
@ljharb any news on this one?
No, "help wanted" means it's awaiting a PR.
Hi @hawkrives ,
I have added a PR, Can you check the test cases?
@tanmoyopenroot we must depend on localeCompare whenever possible since english isn't the only language in the world.
@ljharb But each character in a string in any language will be compared in Unicode order for comparison operator.
In Unicode everything is ordered alphabetically.
If that were true, there'd be no point in the localeCompare method existing.
I will try to fix it using localeCompare.