From: Dave Thomas Date: 2000-07-02T11:11:12-05:00 Subject: [ruby-talk:03744] Re: CGI module and form fields values Jilani Khaldi writes: > running this code: > .. > cgi = CGI.new > h = cgi.params > h.each_key {|key| print key, "
"} > .. > How to get in output the fields and their value in the same order as > they are in the form? A hash is not ordered, so you won't be able to have 'each' return the fields in any particular order. A solution might be to give each field a name that includes a prefix: A_name B_address or 00_name 01_address Then you can sort the set of keys before processing them: h.keys.sort.each do |key| ... end Regards Dave