Created
March 12, 2019 20:48
-
-
Save michaeleisel/f589fd254a066c42052bf4c2b2fea975 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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