-
Notifications
You must be signed in to change notification settings - Fork 464
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
Sort command does not use the same sorting scheme as Xcode #615
Comments
Pull requests improving the group sorting algorithm are very welcome! |
Oh, good case with ["A1B001", "A01B1"], it's not even the same order as the Finder.
I'll try to implement the Xcode rule in ruby. |
OK, here is my ruby implementation: [edit] see pull request #677 now, and in particular file https://github.com/CocoaPods/Xcodeproj/blob/ca7b41deb38f43c14d066f62a55edcd53876cd07/lib/xcodeproj/project/object/helpers/sort_helper.rb |
@barakwei @segiddins Anything else to be solved, here? |
Sorry for missing the discussion, I only noticed it now. In addition, I suggest adding files with "multiple extensions" like Mixing between the two lists is also a good idea, there are probably many edge cases. Good luck! |
@barakwei I mean: please look at my pull request #677: all those cases should pass already. Have a try from my branch https://github.com/Coeur/Xcodeproj/tree/xcode_sort. |
I've tried it. Unfortunately, it doesn't match Xcode's sorting. I suggest to add them to the test of this class in any case. This is how Xcode sorts them (just like Finder, at least on my machine):
Your sorting produces a different result:
From what I understand, Finder uses |
Well, basically Xcode sorts a dot |
Actually, I found more cases failing with my original sorting: notably unicode characters, and that's a bit more tricky. Ah, if only the Xcode sort behavior was documented! [edit] And some useful test cases and discussion at https://discussions.apple.com/thread/7602542 |
From what I see, Xcode sorts like Finder. If you want to sort like finder you can call |
I figured that. But solving the unicode sort may require activesupport, with either |
And also, I just found that Xcode lists duplicate references at the end of everything else... that's yet another edge case that would need extra code to solve. |
In the mean time, the problem with the dots should now be solved in the PR. And for any new case that we may discover, it'll be worth checking if it's a regression compared to the plain sort algorithm or just some feature-request. As you said in your original post: "fixing the most simple case is sufficient". |
Looks like the latest code works on my use cases. Note that I provide the strings directly to the class and I do not separate the base name and extension, I guess the PR should do this as well. Yes, I agree that the most important things are punctuations, numbers, spaces, and letters. If solving Unicode will be more complex, it can be done by demand as you say. Lastly, I want to thank you for taking the time to implement this feature. I'll surely use it. |
I've just found out that Xcode sorting is broken (unpredictable, weak, not strict) and I've opened a radar regarding it: http://www.openradar.me/radar?id=5012044621283328 So it's currently undesirable to follow exactly Xcode sorting on some edge cases (a strong strict total sorting is preferable, unless there is a big performance hit for that). |
Xcode supports sorting group by right clicking on the group and choosing "Sort by Name".
If you have a group with two files -
A10.h
andA2.h
, for example, Xcode will putA2.h
first.xcodeproj sort
command will do the simple alphabetic sort and putA10.h
first.The scheme used by Xcode is weird (try sorting A1 and A01, or even better A1B01, and A01B1). If someone accidentally knows what's the exact sorting scheme it will be great, but fixing the most simple case is sufficient.
The text was updated successfully, but these errors were encountered: