Swift: Best way to filter an array
<p>I have an array with <code>student objects</code> and another array with <code>goodStrudentId</code>. I need to fetch all the student objects from <code>students</code> array following sequence of <code>goodStrudentId</code>.
Using multiple forloop i can able to solve this, but i want to learn the best way to solve this issue. My only problem is following sequence of <code>goodStrudentId</code>.
Here is a sample code to understand my problem - </p>

<pre><code>class Student {
    var s_id : String
    var s_name : String
    init(i: String, n: String) {
        self.s_id = i;
        self.s_name = n;
    }
}

var students = [Student(i: "1",n: "a"),
                Student(i: "2",n: "b"),
                Student(i: "3",n: "c"),
                Student(i: "4",n: "d"),
                Student(i: "5",n: "e")]

var goodStudentsId = ["5","2"]

var goodStudentObject = getGoodStudentObjectUsingId(students:students, gdStudentsId:goodStudentsId)



/*
 Expected answer:
 var goodStudentObject = [Student(i: "5",n: "e"), Student(i: "2",n: "b")]

 */

func getGoodStudentObjectUsingId(students:Array&lt;Student&gt;, gdStudentsId:Array&lt;String&gt;) -&gt; Array&lt;Student&gt;! {
    /*?????? please complete this func*/
    return [];
}
</code></pre>