DRY up code by removing excess hash-value.sort! calls (replacing with loops)