addressable/uri按字母顺序给出参数。如果我想获取哈希中的查询参数(即随机数、方法、速率、order_type、数量),我应该如何更改我的代码?
2.1.0 :060 > require "addressable/uri"
2.1.0 :061 > uri = Addressable::URI.new
2.1.0 :062 > uri.query_values = Hash["nonce" => 1405069051840, "method" => "a", "rate" => "rate", "order_type" => "order_type", "quantity" => "quantity"]
=> {"nonce"=>1405069051840, "method"=>"a", "rate"=>"rate", "order_type"=>"order_type", "quantity"=>"quantity"}
2.1.0 :063 > params = uri.query
=> "method=a&nonce=1405069051840&order_type=order_type&quantity=quantity&rate=rate"
我需要这样的输出:(当我通过时)
"nonce=1405069051840&method=a&rate=rate&order_type=order_type&quantity=quantity"
现在的输出是(字母顺序)
"method=a&nonce=1405069051840&order_type=order_type&quantity=quantity&rate=rate"