I have an array of restaurantsIds in a specific order. I make a network call to get Restaurants for each one of these ids. I am returned with all the Restaurants in the order that they are returned. Restaurants is a custom class and one of the properties is restaurantId. I want to sort the returned Restaurants in the order of the IDs. How would I do that? I think I am supposed to use the sorted function. How would I go upon doing this? There can be duplicate restaurants so I can't use a dictionary to do it. If is is a duplicate restaurant that is returned then it doesn't really matter which instance of that restaurants comes first.
var restaurantIds = [947575, 858914, 255964]
var returnedRestaurant:[Restaurant]!
returnedRestaurant.sorted { (rest1, rest2) -> Bool in
//How would I go about matching rest1 and rest2 to the list of restaurantIds above?
rest1.productID......
}