Remove "then"s in if statements
Use empty? to simply conditions
Replace has_key? with `||=` syntax
Use sort_by to replace sort
Use set operation to test haystack
Use is_a? to compare class
Merge pull request #1 from dlackty/refactor

Slightly refactor some codes