I am parsing a log file and reading line by line in ruby
I will get 2 values like:
iphone mobile
mobile iphone
kindle amazon
amazon kindle
What I need is count i.e. though both the values are swapped like (a,b) and (b,a) ..but it should be counted as 1 and need result as follows
“iphone mobile” => 2
“kindle amazon” => 2
Thank you!
Here is something that will work. A sorted array of the input line is used as the key for the hash: