[swift-evolution] [Proposal] Add .order() family of methods to Collection
milos at milos-and-slavica.net
Mon Apr 11 14:36:20 CDT 2016
> On 11 Apr 2016, at 19:38, Taras Zakharko <taras.zakharko at uzh.ch <mailto:taras.zakharko at uzh.ch>> wrote:
> Your version might be faster for collection with expensive element access, but it should be slower for arrays and the like, as it involves additional intermediate structure allocations and copies.
No, not really. The cost of my enumeration and mapping is linear so they add nothing to the sorting order of complexity. Your two subscript calls inside the predicate, however, definitely do. In other words, your implementation will not be faster under any circumstances and it will in fact grow nonlinearly slower compared to the enumeration approach as the length of array increases…
(My message appear to have bounced: I’m sorry if I end up sending multiple copies!)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution