Month: June 2007
-
Sorting hash by values
Sorting hash by values is quite straightforward. You don’t have to search long to find this example in Ruby documentation: h.sort {|a,b| a[1] <=> b[1]} sort method takes hash converts it in array of two elements arrays and then sort it as an array. When called without code block, sorts hash by keys. But when…
-
Proper RHTML tags for each loops
Last night and this morning I have wasted few hours trying to move forward, over some stupid issue. I was parsing XML data with Hpricot, and since it was my first approach to problem, I was just dumping to output some fields from XML data. And here my frustration began. Since output from my views…