mercredi 6 mai 2015

Sort Parse Query based on difference with Float

I want to sort the results of my Parse Query based on the scalar distance from the field temperature to my variable referenceTemp

I tried the following, which of course does not work, but it illustrates my intention

var referenceTemp = 47.89
var query = PFQuery(className: "Temperatures")
query.orderByAscending("abs(temperature - referenceTemp)")

How can I do it? Thanks!!

Aucun commentaire:

Enregistrer un commentaire