lionheart / openradar-mirror

A mirror of radars pulled from http://openradar.me/.
245 stars 17 forks source link

50854433: Xcode Sort by Name is doing weak ordering with Unicode #21264

Open openradar-mirror opened 5 years ago

openradar-mirror commented 5 years ago

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