Method to_hash for class Array to convert array to hash

Method to_hash converts an array into hash with key as the length of the element and value as array of element of that length.