// RUN: %target-swift-frontend -typecheck %s extension Sequence { func sorted>(by keyPath: K) -> Array { self.sorted { $0[keyPath:keyPath] < $1[keyPath:keyPath] } } } struct Foo { let a: Int } func main() { print([Foo(a: 2), Foo(a:1), Foo(a:4), Foo(a:3)].sorted(by: \Foo.a)) } main()