@@ -126,9 +126,9 @@ orderingExplanation = """\
126
126
/// is, for any elements `a`, `b`, and `c`, the following conditions must
127
127
/// hold:
128
128
///
129
- /// - `isOrderedBefore (a, a)` is always `false`. (Irreflexivity)
130
- /// - If `isOrderedBefore (a, b)` and `isOrderedBefore (b, c)` are both `true`,
131
- /// then `isOrderedBefore (a, c)` is also `true`. (Transitive
129
+ /// - `areInIncreasingOrder (a, a)` is always `false`. (Irreflexivity)
130
+ /// - If `areInIncreasingOrder (a, b)` and `areInIncreasingOrder (b, c)` are both `true`,
131
+ /// then `areInIncreasingOrder (a, c)` is also `true`. (Transitive
132
132
/// comparability)
133
133
/// - Two elements are *incomparable* if neither is ordered before the other
134
134
/// according to the predicate. If `a` and `b` are incomparable, and `b`
@@ -165,7 +165,7 @@ extension MutableCollection
165
165
/// This method is typically one step of a sorting algorithm. A collection is
166
166
/// partitioned around a pivot index when each of the elements before the
167
167
/// pivot is correctly ordered before each of the elements at or after the
168
- /// pivot. The `partition(isOrderedBefore :)` method reorders the elements of
168
+ /// pivot. The `partition(by :)` method reorders the elements of
169
169
/// the collection and returns a pivot index that satisfies this condition,
170
170
/// using the given predicate to determine the relative order of any two
171
171
/// elements.
@@ -197,18 +197,18 @@ ${orderingExplanation}
197
197
/// argument is greater than its second argument, larger elements are
198
198
/// ordered before smaller elements.
199
199
///
200
- /// - Parameter isOrderedBefore : A predicate that returns `true` if its first
200
+ /// - Parameter areInIncreasingOrder : A predicate that returns `true` if its first
201
201
/// argument should be ordered before its second argument; otherwise,
202
202
/// `false`.
203
203
/// - Returns: A pivot index, such that every element before the pivot is
204
204
/// ordered before every element at or above the pivot, using
205
- /// `isOrderedBefore ` to determine the relative order of any two elements.
205
+ /// `areInIncreasingOrder ` to determine the relative order of any two elements.
206
206
/// The returned pivot is equal to the collection's end index only if the
207
207
/// collection is empty.
208
208
///
209
209
/// - SeeAlso: `partition()`
210
210
public mutating func partition(
211
- isOrderedBefore : @noescape ( ${ IElement} , ${ IElement} ) -> Bool
211
+ by areInIncreasingOrder : @noescape ( ${ IElement} , ${ IElement} ) -> Bool
212
212
) -> Index
213
213
214
214
% else :
@@ -248,7 +248,7 @@ ${orderingExplanation}
248
248
/// less than every element at or above the pivot. The returned pivot is
249
249
/// equal to the collection's end index only if the collection is empty.
250
250
///
251
- /// - SeeAlso: `partition(isOrderedBefore :)`
251
+ /// - SeeAlso: `partition(by :)`
252
252
public mutating func partition( ) -> Index
253
253
254
254
% end
@@ -259,7 +259,7 @@ ${orderingExplanation}
259
259
UnsafeMutableBufferPointer ( start: baseAddress, count: count)
260
260
let unsafeBufferPivot = bufferPointer. partition (
261
261
% if preds:
262
- isOrderedBefore : isOrderedBefore
262
+ by : areInIncreasingOrder
263
263
% end
264
264
)
265
265
return unsafeBufferPivot - bufferPointer. startIndex
@@ -272,11 +272,11 @@ ${orderingExplanation}
272
272
typealias EscapingBinaryPredicate =
273
273
( ${ IElement} , ${ IElement} ) - > Bool
274
274
var escapableIsOrderedBefore =
275
- unsafeBitCast ( isOrderedBefore , to: EscapingBinaryPredicate . self)
275
+ unsafeBitCast ( areInIncreasingOrder , to: EscapingBinaryPredicate . self)
276
276
return _partition(
277
277
& self ,
278
278
subRange: startIndex..< endIndex,
279
- isOrderedBefore : & escapableIsOrderedBefore)
279
+ by : & escapableIsOrderedBefore)
280
280
% else:
281
281
return _partition( & self , subRange: startIndex..< endIndex)
282
282
% end
@@ -313,15 +313,15 @@ extension ${Self} where Self.Iterator.Element : Comparable {
313
313
/// // Prints "["Abena", "Akosua", "Kofi", "Kweku", "Peter"]"
314
314
///
315
315
/// To sort the elements of your ${sequenceKind} in descending order, pass the
316
- /// greater-than operator (`>`) to the `sorted(isOrderedBefore :)` method.
316
+ /// greater-than operator (`>`) to the `sorted(by :)` method.
317
317
///
318
- /// let descendingStudents = students.sorted(isOrderedBefore : >)
318
+ /// let descendingStudents = students.sorted(by : >)
319
319
/// print(descendingStudents)
320
320
/// // Prints "["Peter", "Kweku", "Kofi", "Akosua", "Abena"]"
321
321
///
322
322
/// - Returns: A sorted array of the ${sequenceKind}'s elements.
323
323
///
324
- /// - SeeAlso: `sorted(isOrderedBefore :)`
324
+ /// - SeeAlso: `sorted(by :)`
325
325
/// ${'- MutatingVariant: sort' if Self == 'MutableCollection' else ''}
326
326
public func sorted( ) -> [ Iterator . Element ] {
327
327
var result = ContiguousArray ( self )
@@ -342,7 +342,7 @@ extension ${Self} {
342
342
///
343
343
${ orderingExplanation}
344
344
/// The sorting algorithm is not stable. A nonstable sort may change the
345
- /// relative order of elements for which `isOrderedBefore ` does not
345
+ /// relative order of elements for which `areInIncreasingOrder ` does not
346
346
/// establish an order.
347
347
///
348
348
/// In the following example, the predicate provides an ordering for an array
@@ -375,10 +375,10 @@ ${orderingExplanation}
375
375
/// You also use this method to sort elements that conform to the
376
376
/// `Comparable` protocol in descending order. To sort your ${sequenceKind}
377
377
/// in descending order, pass the greater-than operator (`>`) as the
378
- /// `isOrderedBefore ` parameter.
378
+ /// `areInIncreasingOrder ` parameter.
379
379
///
380
380
/// let students: Set = ["Kofi", "Abena", "Peter", "Kweku", "Akosua"]
381
- /// let descendingStudents = students.sorted(isOrderedBefore : >)
381
+ /// let descendingStudents = students.sorted(by : >)
382
382
/// print(descendingStudents)
383
383
/// // Prints "["Peter", "Kweku", "Kofi", "Akosua", "Abena"]"
384
384
///
@@ -387,22 +387,22 @@ ${orderingExplanation}
387
387
///
388
388
/// print(students.sorted())
389
389
/// // Prints "["Abena", "Akosua", "Kofi", "Kweku", "Peter"]"
390
- /// print(students.sorted(isOrderedBefore : <))
390
+ /// print(students.sorted(by : <))
391
391
/// // Prints "["Abena", "Akosua", "Kofi", "Kweku", "Peter"]"
392
392
///
393
- /// - Parameter isOrderedBefore : A predicate that returns `true` if its first
393
+ /// - Parameter areInIncreasingOrder : A predicate that returns `true` if its first
394
394
/// argument should be ordered before its second argument; otherwise,
395
395
/// `false`.
396
396
/// - Returns: A sorted array of the ${sequenceKind}'s elements.
397
397
///
398
398
/// - SeeAlso: `sorted()`
399
399
/// ${'- MutatingVariant: sort' if Self == 'MutableCollection' else ''}
400
400
public func sorted(
401
- isOrderedBefore :
401
+ by areInIncreasingOrder :
402
402
@noescape ( ${ IElement} , ${ IElement} ) -> Bool
403
403
) -> [ Iterator . Element ] {
404
404
var result = ContiguousArray ( self )
405
- result. sort ( isOrderedBefore : isOrderedBefore )
405
+ result. sort ( by : areInIncreasingOrder )
406
406
return Array ( result)
407
407
}
408
408
}
@@ -433,9 +433,9 @@ extension MutableCollection
433
433
/// // Prints "["Abena", "Akosua", "Kofi", "Kweku", "Peter"]"
434
434
///
435
435
/// To sort the elements of your collection in descending order, pass the
436
- /// greater-than operator (`>`) to the `sort(isOrderedBefore :)` method.
436
+ /// greater-than operator (`>`) to the `sort(by :)` method.
437
437
///
438
- /// students.sort(isOrderedBefore : >)
438
+ /// students.sort(by : >)
439
439
/// print(students)
440
440
/// // Prints "["Peter", "Kweku", "Kofi", "Akosua", "Abena"]"
441
441
public mutating func sort( ) {
@@ -464,7 +464,7 @@ extension MutableCollection where Self : RandomAccessCollection {
464
464
///
465
465
${ orderingExplanation}
466
466
/// The sorting algorithm is not stable. A nonstable sort may change the
467
- /// relative order of elements for which `isOrderedBefore ` does not
467
+ /// relative order of elements for which `areInIncreasingOrder ` does not
468
468
/// establish an order.
469
469
///
470
470
/// In the following example, the closure provides an ordering for an array
@@ -501,35 +501,35 @@ ${orderingExplanation}
501
501
/// predicate.
502
502
///
503
503
/// var students = ["Kofi", "Abena", "Peter", "Kweku", "Akosua"]
504
- /// students.sort(isOrderedBefore : >)
504
+ /// students.sort(by : >)
505
505
/// print(students)
506
506
/// // Prints "["Peter", "Kweku", "Kofi", "Akosua", "Abena"]"
507
507
///
508
- /// - Parameter isOrderedBefore : A predicate that returns `true` if its first
508
+ /// - Parameter areInIncreasingOrder : A predicate that returns `true` if its first
509
509
/// argument should be ordered before its second argument; otherwise,
510
510
/// `false`.
511
511
public mutating func sort(
512
- isOrderedBefore :
512
+ by areInIncreasingOrder :
513
513
@noescape ( ${ IElement} , ${ IElement} ) -> Bool
514
514
) {
515
515
typealias EscapingBinaryPredicate =
516
516
( Iterator . Element , Iterator . Element ) -> Bool
517
517
let escapableIsOrderedBefore =
518
- unsafeBitCast ( isOrderedBefore , to: EscapingBinaryPredicate . self)
518
+ unsafeBitCast ( areInIncreasingOrder , to: EscapingBinaryPredicate . self)
519
519
520
520
let didSortUnsafeBuffer : Void ? =
521
521
_withUnsafeMutableBufferPointerIfSupported {
522
522
( baseAddress, count) -> Void in
523
523
var bufferPointer =
524
524
UnsafeMutableBufferPointer ( start: baseAddress, count: count)
525
- bufferPointer. sort ( isOrderedBefore : escapableIsOrderedBefore)
525
+ bufferPointer. sort ( by : escapableIsOrderedBefore)
526
526
return ( )
527
527
}
528
528
if didSortUnsafeBuffer == nil {
529
529
_introSort (
530
530
& self ,
531
531
subRange: startIndex..< endIndex,
532
- isOrderedBefore : escapableIsOrderedBefore)
532
+ by : escapableIsOrderedBefore)
533
533
}
534
534
}
535
535
}
@@ -633,7 +633,7 @@ ${subscriptCommentPost}
633
633
634
634
extension MutableCollection where Self : Rando mAccessCollection {
635
635
636
- @available ( * , unavailable, message: " slice the collection using the range, and call partition(isOrderedBefore :) " )
636
+ @available ( * , unavailable, message: " slice the collection using the range, and call partition(by :) " )
637
637
public mutating func partition(
638
638
_ range: Range < Index > ,
639
639
isOrderedBefore: ( ${ IElement} , ${ IElement} ) -> Bool
@@ -663,7 +663,7 @@ extension MutableCollection
663
663
}
664
664
665
665
extension MutableCollection where Self : RandomAccessCollection {
666
- @available ( * , unavailable, renamed: " sort(isOrderedBefore :) " )
666
+ @available ( * , unavailable, renamed: " sort(by :) " )
667
667
public mutating func sortInPlace(
668
668
_ isOrderedBefore: @noescape ( Iterator . Element , Iterator . Element ) -> Bool
669
669
) {
0 commit comments