{"action":"closed","issue":{"url":"https://api.github.com/repos/handsontable/handsontable/issues/883","repository_url":"https://api.github.com/repos/handsontable/handsontable","labels_url":"https://api.github.com/repos/handsontable/handsontable/issues/883/labels{/name}","comments_url":"https://api.github.com/repos/handsontable/handsontable/issues/883/comments","events_url":"https://api.github.com/repos/handsontable/handsontable/issues/883/events","html_url":"https://github.com/handsontable/handsontable/issues/883","id":16715978,"number":883,"title":"Trouble sorting column of type 'numeric'","user":{"login":"mludlum","id":3731744,"avatar_url":"https://avatars.githubusercontent.com/u/3731744?v=3","gravatar_id":"","url":"https://api.github.com/users/mludlum","html_url":"https://github.com/mludlum","followers_url":"https://api.github.com/users/mludlum/followers","following_url":"https://api.github.com/users/mludlum/following{/other_user}","gists_url":"https://api.github.com/users/mludlum/gists{/gist_id}","starred_url":"https://api.github.com/users/mludlum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mludlum/subscriptions","organizations_url":"https://api.github.com/users/mludlum/orgs","repos_url":"https://api.github.com/users/mludlum/repos","events_url":"https://api.github.com/users/mludlum/events{/privacy}","received_events_url":"https://api.github.com/users/mludlum/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/handsontable/handsontable/labels/Change","name":"Change","color":"0052cc"},{"url":"https://api.github.com/repos/handsontable/handsontable/labels/Plugin:%20column%20sorting","name":"Plugin: column sorting","color":"009800"},{"url":"https://api.github.com/repos/handsontable/handsontable/labels/Priority:%20normal","name":"Priority: normal","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2013-07-13T15:05:19Z","updated_at":"2016-02-23T11:12:51Z","closed_at":"2016-02-23T11:12:51Z","body":"I have set a column to be type 'numeric'.  The underlying data is integer strings.  I expected the data type to be honored when sorting but it does not.  As a workaround, I tried formatting with leading zeroes, but it does not seem that Numeral.js supports leading zeros.    I also would like the empty row to be at the bottom and requested in another issue.\r\n\r\nSo, I made this change to the sort function.  What do you think?\r\n```javascript\r\n    this.sortIndex.sort(function (a, b) {\r\n      var type = instance.view.settings.columns[instance.sortColumn].type;\r\n      var a1 = a[1];\r\n      var b1 = b[1]\r\n      if (type === 'numeric')\r\n      {\r\n          try\r\n          {\r\n              if (a1 !== null)\r\n                  a1 = Number(a1);\r\n              if (b1 !== null)\r\n                  b1 = Number(b1);\r\n          }\r\n          catch (e)\r\n          {\r\n\r\n          }\r\n      }\r\n      if (a1 === b1) {\r\n        return 0;\r\n      }\r\n      if (a1 === null) {\r\n        return 1;\r\n      }\r\n      if (b1 === null) {\r\n        return -1;\r\n      }\r\n      if (a1 < b1) return instance.sortOrder ? -1 : 1;\r\n      if (a1 > b1) return instance.sortOrder ? 1 : -1;\r\n      return 0;\r\n    });\r\n    sortingEnabled = true;\r\n  };\r\n```"}}