That's pretty similar to what I was already doing. I ended up finalizing on this, which will be easier to understand in the future. var prevColumn = sorted[0].column var startIndex = 0 var byColumnAndRow: [[Match]] = [] for (index, match) in sorted.enumerate() { guard prevColumn != match.column else { continue } let column = Array(sorted[startIndex ..< index]) byColumnAndRow.append(column) startIndex = index prevColumn = match.column } // The previous enumeration won't grab the very last column worth of matches because the // loop ends before the column changes again. byColumnAndRow.append(Array(sorted[startIndex ..< sorted.count]))
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: