Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/gvoice-ruby/compatibility.rb

Instance Method Summary collapse

Instance Method Details

#sort_by!(&given_proc) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/gvoice-ruby/compatibility.rb', line 49

def sort_by!(&given_proc)
  if block_given?
    self.sort! { |a,b| given_proc.call(a) <=> given_proc.call(b) }
  else
    raise ArgumentError "No valid proc object created from argument."
  end
end