I think `@dates = Hash[@dates.sort{|a,b| a[0] <=> b[0] }]` will do the same as these six lines of code.