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