A Rails controller receives the POST values in a hash, which has no natural order, but for my application I need it, because the user can change the order of the form fields via Javascript. (via Sortable from jQuery)
Is there any other way to retrieve the posted values in their original ordering?
Unless you parse the raw post data, it will probably be in a hash anyway. And since hashes aren’t ordered, you’re screwed.
You can have it passed as an array, though, maintaining the ordering, by making use of Rails’ params magics. E.g. “foo[]=bar&foo[]=baz&foo=maz” (same goes for POST params) will give you
["bar", "baz", "maz"]forparams[:foo]