Sorting compares the element with itself

I am curious, why sorted(by:) tries to compare the element with itself? I've noticed that when sorting a list of files, but it is quite easy to make a reproducer:

Can you try this in Swift 5? The sort algorithm in Swift 4.2 used partitioning, which apparently may have compared elements against themselves.

1 Like

It does work with Swift 5. Thanx for the explanation!

1 Like
Terms of Service

Privacy Policy

Cookie Policy