Created
March 6, 2019 22:08
-
-
Save michaeleisel/88fb4808ab4867169385e7f01830d3ad 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>(_ comparableTransform: (Array.Element) -> T) -> [Array.Element] { | |
return sorted(by: { (a, b) -> Bool in | |
return comparableTransform(a) > comparableTransform(b) | |
}) | |
} | |
} | |
let carts: [Card] = [] | |
carts = carts.sortedWith({ (cart) -> (Int, Int) in // generic parameter error here | |
let c: (Int, Int) = (cart.rowIndex, cart.columnIndex) | |
return c | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment