Skip to content

Instantly share code, notes, and snippets.

@michaeleisel
Created March 12, 2019 20:48
Show Gist options
  • Select an option

  • Save michaeleisel/f589fd254a066c42052bf4c2b2fea975 to your computer and use it in GitHub Desktop.

Select an option

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