Support Ruby 1.8

.sort_by does not work for Ruby1.8