parse.com - swift parse query orderbyDescending doesn't work -


i using swift , parse. used 'query.orderbydescending' in way doesn't work perfectly. want arrange people's total score order looks (e.g., 9, 7, 32, 21, 15....). seems coding recognize first digit of number. how can fix it? here's codes. thank you!

class individualstatstvc: uitableviewcontroller {  var postsarray = [pfobject]()  override func viewdidload() {     super.viewdidload()      self.view.backgroundcolor = uicolor(patternimage: uiimage(named: "background2.png")!)     tableview.separatorcolor = uicolor.orangecolor()      fetchdata()     print(postsarray) }  override func numberofsectionsintableview(tableview: uitableview) -> int {     return 1 }  override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {     return postsarray.count }   override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {     let cell = tableview.dequeuereusablecellwithidentifier("indistats", forindexpath: indexpath) as! individualstatstvcell      cell.yourname?.text = postsarray[indexpath.row].objectforkey("name") as? string     cell.label1?.text = postsarray[indexpath.row].objectforkey("win") as? string     cell.label2?.text = postsarray[indexpath.row].objectforkey("draw") as? string     cell.label3?.text = postsarray[indexpath.row].objectforkey("lose") as? string     cell.label4?.text = postsarray[indexpath.row].objectforkey("aceerror") as? string     cell.label5?.text = postsarray[indexpath.row].objectforkey("total") as? string     return cell }  //cell color func colorforindex(index: int) -> uicolor {     let itemcount = postsarray.count - 1     let color = (cgfloat(index) / cgfloat(itemcount)) * 1.0     return uicolor(red: 1.0, green: color, blue: 0.0, alpha: 0.1) }  override func tableview(tableview: uitableview, willdisplaycell cell: uitableviewcell,     forrowatindexpath indexpath: nsindexpath) {         cell.backgroundcolor = colorforindex(indexpath.row) }  func fetchdata(){     //empty postsarray     postsarray = []     //bring data parse     let query = pfquery(classname: "individualstats")    query.orderbydescending("total")     // postsarray.sortinplace({($0["total"] as! int) > ($1["total"] as! int)})    query.findobjectsinbackgroundwithblock { (objects: [pfobject]?, error) -> void in         if error == nil && objects != nil{             object in objects! {                 self.postsarray.append(object)                 print(self.postsarray)                 self.tableview.reloaddata()             }         }     }} 

from code, seems total string. if so, sort order expected. need store total number.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -