Skip to content

Instantly share code, notes, and snippets.

@manojnaidu619
Created July 4, 2019 16:40
Show Gist options
  • Save manojnaidu619/42e077a76f07101b62f8b079b9cdb3cc to your computer and use it in GitHub Desktop.
Save manojnaidu619/42e077a76f07101b62f8b079b9cdb3cc to your computer and use it in GitHub Desktop.
Ruby Different way of sorting array!
nums = [5,4,3,2,1,1]
a = Array.new
until nums.empty?
min = nums.min
step = nums.count(min)
if step > 1
step.to_i.times do
a << min
end
nums.delete(min)
else
a << nums.min
nums.delete(min)
end
end
p a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment