Created
February 28, 2018 14:00
-
-
Save vialyx/26b7e978d4867a00d344e7a2f70b9a65 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
users = ["123": User(name: "Max Guest"), "222": User(name: "Mark Towrn"), "333": User(name: "James Jo")] | |
let grouppedByFirstNameCharacter = Dictionary(grouping: users) { | |
return $0.value.name.first! | |
} | |
print("groupped: \(grouppedByFirstNameCharacter)") | |
// groupped: ["J": [(key: "333", value: __lldb_expr_82.User(name: "James Jo"))], "M": [(key: "222", value: __lldb_expr_82.User(name: "Mark Towrn")), (key: "123", value: __lldb_expr_82.User(name: "Max Guest"))]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment