I have two arrays:
@State var myInterests: [String] = ["Beer", "Food", "Dogs", "Ducks"]
@State var otherInterests: [String] = ["Ducks", "Baseball", "Beer", "Pasta"]
I need to display a list with all shared interests listed first (top of the list), and then the others after.
ForEach(interests, id: \.self) { tag in
Text(tag)
}
The result for otherInterests should be something like:
["Ducks", "Beer", "Baseball", "Pasta"]
Is there any way of sorting the array to move the shared interests to the front of the array and the remaining ones after?