Update sort.rb

omitted mapping counts array to 0
fixed nilclass error while trying to count to an index containing nil
omitted reducing the counts array values
fixed nilclass error while trying to iterate nil times while reconstructing container