PFQuery from an array in order SWIFT -


i want use parse pfquery query array of objects, want outcome in order have put in, example:

var age = [26, 28, 30, 20]  var agequery = pfuser.query() agequery.wherekey("age", containedin: age)    let finalresult = agequery.findobjects()    println(finalresult) // equal search in order have put them in, first result should 26, 28 etc. 

is there of searching in order put in?

thanks

i don't believe so. documentation doesn't promise order of results.

your best option sort results once have received them. consider using sortedarrayusingcomparator , each object you're comparing find index in source array , use indexes decide resulting nscomparisonresult.

in swift seems can shortcut little, along lines of:

var sortedresult = sorted(finalresult) { (obj1, obj2) in      let p1 = obj1 person     let p2 = obj2 person      let index1 = find(age, p1.age)!     let index2 = find(age, p2.age)!      return index1 < index2 } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -