Skip to content

Instantly share code, notes, and snippets.

@michaeleisel
Created March 12, 2019 20:48
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 michaeleisel/f589fd254a066c42052bf4c2b2fea975 to your computer and use it in GitHub Desktop.
Save michaeleisel/f589fd254a066c42052bf4c2b2fea975 to your computer and use it in GitHub Desktop.
extension Array {
func sortedWith<T: Comparable>(_ comparableTransform: (Array.Element) -> T) -> [Array.Element] {
return sorted(by: { (a, b) -> Bool in
return comparableTransform(a) > comparableTransform(b)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment