Search code examples
iosrelationshipentity-relationshipswift3cosmicmind

Sort a relationship in cosmicmind graph's library


I'm using the graph library and I need sort a relationship from a relationship.subject field [ " idOrder " ] . it's possible to do it? And if IdOrder isn't a int but a date?


Solution

  • yes you can do this for Swift 3, which is currently in the development branch.

    _ = graph.search(forRelationship: ["T1"]).sorted { (a, b) -> Bool in
            return a.subject!["idOrder"] as! Int > b.subject!["idOrder"] as! Int
        }
    

    All the best :)