🚧 This post is under construction 🚧

extension ${Self} where Self.Iterator.Element : Comparable in swift/stdlib/public/core/CollectionAlgorithms.swift.gyb

[_introSortImpl in swift/stdlib/public/core/Sort.swift.gyb][2]

func _introSortImpl<C>(
  _ elements: inout C,
  subRange range: Range<C.Index>
  ${", by areInIncreasingOrder: (C.Iterator.Element, C.Iterator.Element) -> Bool" if p else ""},
  depthLimit: Int
) where
  C : MutableCollection & RandomAccessCollection
  ${"" if p else ", C.Iterator.Element : Comparable"}

swift/stdlib/public/core/CollectionAlgorithms.swift.gyb swift/stdlib/public/core/Sort.swift.gyb Swift sorting algorithm implementation


  • Arrays.swift.gyb -> Arrays.swift after running build-script -x.
  • In Arrays.swift, there are struct Array<Element>, struct ContiguousArray<Element>, struct ArraySlice<Element>.
  • sorted(), sort() functions are defined in MutableCollection, Sequence protocols.