grouping of array elements according to length in a hash with length as a key