Summary:
The sort algorithm used by Xcode to "Sort by Name" is not a strict sorting algorithm: in some situations, two files may be ordered differently (sometimes one before the other, and sometimes the reverse order). This happens notably when comparing Unicode characters that have the same ASCII transliteration. It also means that Xcode has a broken implementation of the Unicode Collation Algorithm (on which Finder sorting is based on, according to https://support.apple.com/kb/TA22935?locale=en_US).
Steps to Reproduce:
My repro case involves having three files named respectively:
"ffi " (with a space at the end)
"ffi1"
"ffi1" (this is a unicode character followed by a digit, and it needs to be in a different folder from the previous file on some filesystems)
Then we add those files one by one to the same group in an Xcode project.
And finally we use Xcode feature "Sort by Name" on the group.
To understand the setup, I've built such scenario in an xcodeproj and I've attached it to the report. I've made a repository of it at https://github.com/Coeur/XcodeWeakSortByName in case the attachment is deleted.
There are two groups with different initial order (but same files):
tosort-case-1 has initially this order: "ffi ", "ffi1", "ffi1"
tosort-case-2 has initially this order: "ffi1", "ffi ", "ffi1"
Expected Results:
"Sort by Name" should return a unique strict order for the files, no matter how they are previously arranged.
Which means that tosort-case-1 and tosort-case-2 should end up with the same files order after sorting.
Actual Results:
We get multiple different sort results depending on the initial position of the group entries.
From the above and attached setup, applying "Sort by Name" results in:
tosort-case-1 has a final order of: "ffi1", "ffi ", "ffi1"
tosort-case-2 has a final order of: "ffi ", "ffi1", "ffi1"
Version/Build:
Xcode 10.2 on macOS Mojave 10.14.5.
System ruby: ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Configuration:
MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)
Description
Summary: The sort algorithm used by Xcode to "Sort by Name" is not a strict sorting algorithm: in some situations, two files may be ordered differently (sometimes one before the other, and sometimes the reverse order). This happens notably when comparing Unicode characters that have the same ASCII transliteration. It also means that Xcode has a broken implementation of the Unicode Collation Algorithm (on which Finder sorting is based on, according to https://support.apple.com/kb/TA22935?locale=en_US).
Steps to Reproduce: My repro case involves having three files named respectively:
To understand the setup, I've built such scenario in an xcodeproj and I've attached it to the report. I've made a repository of it at https://github.com/Coeur/XcodeWeakSortByName in case the attachment is deleted. There are two groups with different initial order (but same files):
Expected Results: "Sort by Name" should return a unique strict order for the files, no matter how they are previously arranged. Which means that tosort-case-1 and tosort-case-2 should end up with the same files order after sorting.
Actual Results: We get multiple different sort results depending on the initial position of the group entries. From the above and attached setup, applying "Sort by Name" results in:
Version/Build: Xcode 10.2 on macOS Mojave 10.14.5. System ruby: ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Configuration: MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)
- Product Version: Created: 2019-05-16T16:09:47.264808 Originated: 2019-05-17T00:03:00 Open Radar Link: http://www.openradar.me/50854433