-
Notifications
You must be signed in to change notification settings - Fork 72
Fix Sorting of Special Characters #91
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
Conversation
Consider these two lines:
Both good old character code based sorting and Now consider these two lines (
This time, both good old character code based sorting and Finally, how would this plugin like to sort them? Well, it thinks that files further up the directory tree should come first. So, more As you can see, sometimes (the Well, using both sorting methods, all characters that sort before This leads to the current solution in this plugin. It makes sure that If we’re going to stay with that approach, I don’t think it’s possible to tweak the substitutions like you have in this PR. This approach has to sort // Expected order:
import b from "../../-a";
import a from "../-a"; I realize that might be missing from the test suite. |
See #87 (comment). |
@lydell - I apologize, I was busy the whole week with other high priority items, so couldn't get to this issue / PR in time. Thanks for taking the time to put together the explanation. I understand and agree that imports from outer level parents should take higher priority than the inner-level parents. Therefore imports from import y from '../a.b';
import x from '../a-b'; In this case both good old character code based sorting and // Character code based sorting
['../a.b', '../a-b'].sort();
// Output: [ '../a-b', '../a.b' ]
// Intl.Collator based sorting
['../a.b', '../a-b'].sort(new Intl.Collator().compare);
// Output: [ '../a-b', '../a.b' ] The "from" strings on both lines start with import x from '../a-b';
import y from '../a.b'; However, in the current state of this plugin, import y from '../a.b';
import x from '../a-b'; This was the main problem that I was trying to describe in issue #87. |
@lydell - Sorry, I posted my comments above before reading the updated
Since you have decided you don't care - I will stop bothering you. Thank you for your time. |
DRAFT PR WITH INCOMPLETE THOUGHTS - DO NOT MERGE
TODO:
'.//'
../-a
vs../,
)