Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dubadub/topo_sort
https://github.com/dubadub/topo_sort
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/dubadub/topo_sort
- Owner: dubadub
- License: mit
- Created: 2014-06-07T16:00:46.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-06-07T16:36:36.000Z (over 10 years ago)
- Last Synced: 2024-12-24T06:36:45.709Z (about 1 month ago)
- Language: Ruby
- Size: 125 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# TopoSort
Take a hash of elements and their dependencies and sort
them in an order where each element required is before
the elements that require it.Note. Each element can have only one dependency.
## Installation
Add this line to your application's Gemfile:
gem 'topo_sort'
And then execute:
$ bundle
Or install it yourself as:
$ gem install topo_sort
## Example usage
nodes = { 'a' => nil, 'b' => 'c', 'c' => 'f', 'd' => 'a', 'e' => 'b', 'f' => nil }
TopoSort.sort(nodes)
#=> ["a", "f", "c", "b", "d", "e"]## Run tests
Run tests with:
rake