Jilani Khaldi <jilanik / tin.it> writes:

> running this code:
> ..
> cgi = CGI.new
> h = cgi.params
> h.each_key {|key| print key, "<br>"}
> ..
> 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