def normalize_nested_query(value, prefix = nil)
      case value
      when Array
        value.map do |v|
          normalize_nested_query(v, "#{prefix}[]")
        end.flatten.sort
      when Hash
        value.map do |k, v|
          normalize_nested_query(v, prefix ? "#{prefix}[#{k}]" : k)
        end.flatten.sort
      else
        [escape(prefix), escape(value)] * "="
      end
    end
def normalize_nested_query(value, prefix = nil)
      case value
      when Array
        value.map do |v|
          normalize_nested_query(v, "#{prefix}[]")
        end.flatten.sort
      when Hash
        value.map do |k, v|
          normalize_nested_query(v, prefix ? "#{prefix}[#{k}]" : k)
        end.flatten.sort
      else
        [escape(prefix), escape(value)] * "="
      end
    end
Returns a string representation of the Hash like in URL query string
 build_nested_query({:level_1 => {:level_2 => ['value_1','value_2']}}, 'prefix'))
   #=> ["prefix%5Blevel_1%5D%5Blevel_2%5D%5B%5D=value_1", "prefix%5Blevel_1%5D%5Blevel_2%5D%5B%5D=value_2"]