When we insert the data into a ruby hash it reorders the data in some other order when we use it in view file.So there are cases when we have to show the data in the same order in the order we are inserting the data into ruby hash.So in case where we have to maintain the order we should use OrderedHash in replacement of Hash.The syntax is as follows:
**hash_name = ActiveSupport::OrderedHash.new**
where hash_name is the name of the hash
For example: If we insert Jan,Feb,Mar,April etc in this case it will basically maintains the order of the hash.
0 Comment(s)