mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
stdlib: de-underscore sort() and partition() methods
Swift SVN r28839
This commit is contained in:
@@ -675,26 +675,16 @@ extension ${Self} : _ArrayType {
|
||||
return Swift.join(self, elements)
|
||||
}
|
||||
|
||||
/// Sort `self` in-place according to `isOrderedBefore`.
|
||||
///
|
||||
/// - Requires: `isOrderedBefore` induces a [strict weak ordering](http://en.wikipedia.org/wiki/Strict_weak_order#Strict_weak_orderings)
|
||||
/// over the elements.
|
||||
public mutating func sort(isOrderedBefore: (T, T) -> Bool) {
|
||||
return withUnsafeMutableBufferPointer {
|
||||
me in Swift.sort(&me, isOrderedBefore)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a copy of `self` that has been sorted according to
|
||||
/// `isOrderedBefore`.
|
||||
///
|
||||
/// - Requires: `isOrderedBefore` induces a
|
||||
/// [strict weak ordering](http://en.wikipedia.org/wiki/Strict_weak_order#Strict_weak_orderings)
|
||||
/// over the elements.
|
||||
@available(*, unavailable, message="call the 'sort()' method on the array")
|
||||
public func sorted(isOrderedBefore: (T, T) -> Bool) -> ${Self} {
|
||||
var result = self
|
||||
result.sort(isOrderedBefore)
|
||||
result.sortInPlace(isOrderedBefore)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user