{"action":"opened","issue":{"url":"https://api.github.com/repos/vega/vega/issues/509","labels_url":"https://api.github.com/repos/vega/vega/issues/509/labels{/name}","comments_url":"https://api.github.com/repos/vega/vega/issues/509/comments","events_url":"https://api.github.com/repos/vega/vega/issues/509/events","html_url":"https://github.com/vega/vega/issues/509","id":130322700,"number":509,"title":"Sorting appears to be broken","user":{"login":"Jerrythafast","id":2095375,"avatar_url":"https://avatars.githubusercontent.com/u/2095375?v=3","gravatar_id":"","url":"https://api.github.com/users/Jerrythafast","html_url":"https://github.com/Jerrythafast","followers_url":"https://api.github.com/users/Jerrythafast/followers","following_url":"https://api.github.com/users/Jerrythafast/following{/other_user}","gists_url":"https://api.github.com/users/Jerrythafast/gists{/gist_id}","starred_url":"https://api.github.com/users/Jerrythafast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jerrythafast/subscriptions","organizations_url":"https://api.github.com/users/Jerrythafast/orgs","repos_url":"https://api.github.com/users/Jerrythafast/repos","events_url":"https://api.github.com/users/Jerrythafast/events{/privacy}","received_events_url":"https://api.github.com/users/Jerrythafast/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-01T10:32:28Z","updated_at":"2016-02-01T10:32:28Z","closed_at":null,"body":"Hey guys,\r\n\r\nI am having difficulties trying to get sorting to work in the following spec (in the [Vega 2.4.2 editor](http://vega.github.io/vega-editor/)).\r\n\r\n```json\r\n{\r\n  \"width\": 400,\r\n  \"height\": 300,\r\n  \"data\": [\r\n    {\r\n      \"name\": \"table\",\r\n      \"values\": [\r\n        {\"item\": \"bbbb\", \"amount\": 10},\r\n        {\"item\": \"dddd\", \"amount\": 6},\r\n        {\"item\": \"eeee\", \"amount\": 6},\r\n        {\"item\": \"ffff\", \"amount\": 4},\r\n        {\"item\": \"aaaa\", \"amount\": 3},\r\n        {\"item\": \"gggg\", \"amount\": 12},\r\n        {\"item\": \"hhhh\", \"amount\": 3},\r\n        {\"item\": \"jjjj\", \"amount\": 3},\r\n        {\"item\": \"cccc\", \"amount\": 3},\r\n        {\"item\": \"iiii\", \"amount\": 2}\r\n      ],\r\n      \"transform\": [{\"type\": \"sort\", \"by\": \"item\"}]\r\n    }\r\n  ],\r\n  \"scales\": [\r\n    {\r\n      \"name\": \"x\",\r\n      \"type\": \"linear\",\r\n      \"range\": \"width\",\r\n      \"domain\": {\"data\": \"table\", \"field\": \"amount\"}\r\n    },\r\n    {\r\n      \"name\": \"y\",\r\n      \"type\": \"ordinal\",\r\n      \"range\": \"height\",\r\n      \"sort\": \"item\",\r\n      \"domain\": {\"data\": \"table\", \"field\": \"item\"}\r\n    }\r\n  ],\r\n  \"axes\": [\r\n    {\"type\": \"x\", \"scale\": \"x\"},\r\n    {\"type\": \"y\", \"scale\": \"y\"}\r\n  ],\r\n  \"marks\": [\r\n    {\r\n      \"type\": \"rect\",\r\n      \"from\": {\"data\": \"table\"},\r\n      \"properties\": {\r\n        \"update\": {\r\n          \"x\": {\"scale\": \"x\", \"value\": 0},\r\n          \"x2\": {\"scale\": \"x\", \"field\": \"amount\"},\r\n          \"y\": {\"scale\": \"y\", \"field\": \"item\", \"offset\": 1},\r\n          \"height\": {\"scale\": \"y\", \"band\": true, \"offset\": -2},\r\n          \"fill\": {\"value\": \"steelblue\"}\r\n        }\r\n      }\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\nI am trying to sort the values on the vertical axis in lexicographical order (though in my 'real-world' spec I would specify a list of columns to sort on because the values are non-unique), but I keep getting them in the order in which the data values are defined. Besides the `sort` transform in the spec above, I have tried various ways of specifying a sort order in the scale definition, but none worked for me and I'm also unsure whether they can handle multi-column sorting rules.\r\n\r\nI was expecting the ordinal scale to take the values in the order in which they leave the `transform` pipeline of the input data if no sorting was applied to the scale itself. I thought it used to work this way in the past, though I might be wrong. It would be a very useful default nonetheless.\r\n\r\nLooking forward to your input!\r\n\r\nKind regards,\r\nJerry"}}