RealmSwift Data Filtering
<p>Let say i have many city object.So,city ID will be my primary key because they can't be duplicate.There will be the same city name,but,different ID and different ShopAddress.Here is my results from json which was from my backend</p>

<pre><code>{
     "CityName" : "NewYork",
     "ID" : 65,
     "CityCode" : "NY",
     "ShopAddress" : "NO.7\/8 17th quarter, 27th Street, LiverPool Township, NewYork."

},
{
    "CityName" : "NewYork",
    "ID" : 89,
    "CityCode" : "NY",
    "ShopAddress" : "NO.7\/8 17th quarter, 40th Street, West Stadium, NewYork."
},
{
    "CityName" : "Maimi",
    "ID" : 150,
    "CityCode" : "MI",
    "ShopAddress" : "NO.7\/8 17th quarter, 40th Street, West Stadium, Maimi."
}...etc
</code></pre>

<p>Here is my realm object</p>

<pre><code>import Foundation
import RealmSwift

class StoreList: Object {

dynamic var storeID : String = ""
dynamic var cityCode : String = ""
dynamic var cityName : String = ""
dynamic var shopAddress :String = ""

override static func primaryKey() -&gt; String? {
    return "storeID"
}

}
</code></pre>

<p>How to get the data of CityNames and appropriate shop address which was concerned with each CityNames?</p>

<pre><code>for (var i = 0; i &lt;= cityname.count; i++) {
        cityItems.append("City Names from realm")
        actualPositions.append(-1)

        var items = [String]()
        for (var i = 0; i &lt; cityName["Newyork"].shopaddress.count; i++) {
            items.append("the locations shop address of each item from each cities")
        }

        self.locationItems.append(items)
    }
</code></pre>

<p>I want to do that because I want to show like that at my accordion table view.<a href="https://i.stack.imgur.com/fQyQY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fQyQY.png" alt="enter image description here"></a></p>

<p>The above code i write is just an example.There will be many mistake.But,i really do need help with filtering.Any Help?</p>