daru

https://github.com/sciruby/daru

Ruby

Data Analysis in RUby

Daru::Vector#sort

Sorts a vector according to its values. If a block is specified, the contents
will be evaluated and data will be swapped whenever the block evaluates
to *true*. Defaults to ascending order sorting. Any missing values will be
put at the end of the vector. Preserves indexing. Default sort algorithm is
quick sort.

== Options

* +:ascending+ - if false, will sort in descending order. Defaults to true.

* +:type+ - Specify the sorting algorithm. Only supports quick_sort for now.
== Usage

  v = Daru::Vector.new ["My first guitar", "jazz", "guitar"]
  # Say you want to sort these strings by length.
  v.sort(ascending: false) { |a,b| a.length <=> b.length }

Source | Google | Stack overflow

Edit

git clone [email protected]:sciruby/daru.git

cd daru

open lib/daru/vector.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Daru--Vector-sort-for-pr


# Commit to git

git add lib/daru/vector.rbgit commit -m "better docs for Daru::Vector#sort"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Daru--Vector-sort-for-pr

hub pull-request


# Celebrate!