Find closest item in array that matches criteria in Swift?
问题 When I have a reference to an item in an array, I'd like to find another item closest to it that matches a certain criteria (forward or backwards). For example, I have this array: let items = [ (a: "Item 1", b: "F", c: 3), (a: "Item 2", b: "S", c: 5), (a: "Item 3", b: "D", c: 7), (a: "Item 4", b: "A", c: 9), (a: "Item 5", b: "M", c: 11), (a: "Item 6", b: "I", c: 13), (a: "Item 7", b: "F", c: 15), (a: "Item 8", b: "S", c: 17), (a: "Item 9", b: "D", c: 19), (a: "Item 10", b: "A", c: 21), (a: