Skip to content

Instantly share code, notes, and snippets.

@fresh5447
Created February 20, 2014 20:40
Show Gist options
  • Select an option

  • Save fresh5447/9122756 to your computer and use it in GitHub Desktop.

Select an option

Save fresh5447/9122756 to your computer and use it in GitHub Desktop.
def sort_by_length(sort_this_array)
sort_this_array.sort {|x,y| x.length <=> y.length}
end
def filter(filter_this_array)
filter_this_array.select {|num| num > 5}
end
filter([1, 3, 7, 8])
sort_by_length [ "d", "a", "e", "c", "b" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment