Last modified: 2013-05-16 00:08:39 UTC
VisualEditor is currently unable to display the parameters in the template editor in the same order as the wikitext because they are provided as a plain object. And per the JSON specification (and as proven by inconsistent behaviour in different browsers), objects are "an unordered set of name/value pairs"[1]. And even if JSON would support it, once in javascript, we have the for-in statement and Object.keys() which do not have a reliable cross-browser logic for the order of the keys. Though Parsoid is able to roundtrip the order (since it has the original wikitext and can put them in the right order), we can't. I'd recommend the output is updated to output an array of some kind. So instead of : { foo: bar, bar: quux } It'd be something like this: [ { foo: bar }, { bar: quux } ] or (Trevor's idea): { keys: ['foo', 'bar'], values: ['bar', 'quux' ] } [1] http://json.org/
Only the name of parameters is significant, the order is a syntactic detail. You can do a numeric sort on numeric parameter names for UI purposes, but generally our API only talks about named parameters.