Skip to content

Instantly share code, notes, and snippets.

@TsRebornz
Last active November 22, 2022 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TsRebornz/a21a61fd0bbb5f3ff54bf1fecb512ca9 to your computer and use it in GitHub Desktop.
Save TsRebornz/a21a61fd0bbb5f3ff54bf1fecb512ca9 to your computer and use it in GitHub Desktop.
extension Sequence {
func sorted<T: Comparable>(by keyPath: KeyPath<Element, T>) -> [Element] {
return sorted {
$0[keyPath: keyPath] < $1[keyPath: keyPath]
}
}
}
let sortedTables = tables.sorted(by: \.size.width)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment