swift sort type array by second type code example Example: swift sort array let sortedUsers = users.sorted { $0.firstName < $1.firstName }