{"action":"created","issue":{"url":"https://api.github.com/repos/pivotal-cf/pivotal-ui/issues/306","labels_url":"https://api.github.com/repos/pivotal-cf/pivotal-ui/issues/306/labels{/name}","comments_url":"https://api.github.com/repos/pivotal-cf/pivotal-ui/issues/306/comments","events_url":"https://api.github.com/repos/pivotal-cf/pivotal-ui/issues/306/events","html_url":"https://github.com/pivotal-cf/pivotal-ui/issues/306","id":113631669,"number":306,"title":"Allow SortableTable to sort cells numerically (or by other rules)","user":{"login":"kayline","id":2092816,"avatar_url":"https://avatars.githubusercontent.com/u/2092816?v=3","gravatar_id":"","url":"https://api.github.com/users/kayline","html_url":"https://github.com/kayline","followers_url":"https://api.github.com/users/kayline/followers","following_url":"https://api.github.com/users/kayline/following{/other_user}","gists_url":"https://api.github.com/users/kayline/gists{/gist_id}","starred_url":"https://api.github.com/users/kayline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kayline/subscriptions","organizations_url":"https://api.github.com/users/kayline/orgs","repos_url":"https://api.github.com/users/kayline/repos","events_url":"https://api.github.com/users/kayline/events{/privacy}","received_events_url":"https://api.github.com/users/kayline/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pivotal-cf/pivotal-ui/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-27T16:59:40Z","updated_at":"2016-01-14T00:19:30Z","closed_at":"2016-01-14T00:19:30Z","body":"SortableTable currently only sorts alphabetically. Support Portal needs to sort numerically, and also using custom rules for a status string. With help from Ryan Dy, we've added on to the SortableTable prototype so that we can pass in a \"sortability\" prop for each cell.\r\nFunctionality:\r\n```\r\nclass CustomSortableTable extends SortableTable {}\r\n\r\nCustomSortableTable.prototype.__reactAutoBindMap.sortedRows = function() {\r\n  var _state = this.state;\r\n  var sortColumn = _state.sortColumn;\r\n  var sortAscending = _state.sortAscending;\r\n  var sortedRows = sortBy(this.props.children, function(row) {\r\n\r\n    var cellForSorting = row.props.children[sortColumn];\r\n\r\n    return cellForSorting.props.sortability || cellForSorting.props.children;\r\n  });\r\n  return sortAscending ? sortedRows : sortedRows.reverse();\r\n};\r\n```\r\nImplementation: \r\n```\r\nrenderTicketItem(ticket, key) {\r\n    var timeInSeconds = new Date(ticket.created_at).getTime();\r\n    var status = this.parseStatusName(ticket.status);\r\n\r\n    return (\r\n      <TableRow className={\"item-row-\" + ticket.id} key={key}>\r\n        <TableCell className='item-row-status' sortability={status.rank}><div className={'label label-' + status.style}>{status.text}</div></TableCell>\r\n        <TableCell className='item-row-id' sortability={ticket.id}>{'#' + ticket.id}</TableCell>\r\n        <TableCell className='item-row-subject'>{ticket.subject}</TableCell>\r\n        <TableCell className='item-row-created' sortability={timeInSeconds}>{this.timeAgo(ticket.created_at)}</TableCell>\r\n        <TableCell className='item-row-severity' sortability={ticket.severity}>{this.parseSeverityName(ticket.severity)}</TableCell>\r\n      </TableRow>\r\n    );\r\n  },\r\n```"},"comment":{"url":"https://api.github.com/repos/pivotal-cf/pivotal-ui/issues/comments/171481365","html_url":"https://github.com/pivotal-cf/pivotal-ui/issues/306#issuecomment-171481365","issue_url":"https://api.github.com/repos/pivotal-cf/pivotal-ui/issues/306","id":171481365,"user":{"login":"atomanyih","id":2305345,"avatar_url":"https://avatars.githubusercontent.com/u/2305345?v=3","gravatar_id":"","url":"https://api.github.com/users/atomanyih","html_url":"https://github.com/atomanyih","followers_url":"https://api.github.com/users/atomanyih/followers","following_url":"https://api.github.com/users/atomanyih/following{/other_user}","gists_url":"https://api.github.com/users/atomanyih/gists{/gist_id}","starred_url":"https://api.github.com/users/atomanyih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atomanyih/subscriptions","organizations_url":"https://api.github.com/users/atomanyih/orgs","repos_url":"https://api.github.com/users/atomanyih/repos","events_url":"https://api.github.com/users/atomanyih/events{/privacy}","received_events_url":"https://api.github.com/users/atomanyih/received_events","type":"User","site_admin":false},"created_at":"2016-01-14T00:19:30Z","updated_at":"2016-01-14T00:19:30Z","body":"https://github.com/pivotal-cf/pivotal-ui/commit/1192cf0017caf08b1efafd80732a2662e95ec6f7"}}