Created
March 12, 2019 21:14
-
-
Save michaeleisel/dd8e2e674af72f3c2fd18310fdbe3bdd to your computer and use it in GitHub Desktop.
This file contains hidden or 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, U: Comparable>(_ comparableTransform: (Array.Element) -> (T, U)) -> [Array.Element] { | |
return sorted(by: { (a, b) -> Bool in | |
let tupleA = comparableTransform(a) | |
let tupleB = comparableTransform(b) | |
return tupleA.0 == tupleB.0 && tupleA.1 == tupleB.1 | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment