Browse files


  • Loading branch information...
1 parent a892d59 commit 0cb6a8ebd75bd3d15c7bfcee5d5511ca51222b49 reiz committed Jan 8, 2012
Showing with 23 additions and 8 deletions.
  1. +21 −6 README.markdown
  2. +2 −2 spec/naturalsorter_spec.rb
@@ -14,7 +14,17 @@ Because the default sort method does not recognize the numbers in the string. Th
`["init20", "init30", "init200"]`
-## How To Use - Examples
+## API
+This GEM has just 2 methods
+`Naturalsorter::Sorter.sort(array, caseinsesitive)`
+And this here for more advanced sorting
+`Naturalsorter::Sorter.sort_by_method(array, method, caseinsesitive)`
+## Installation
You should add this line to your Gemfile
@@ -24,12 +34,17 @@ and run this command in your app root directory
`bundle install`
-Than you can use it like this:
+## How To Use - Examples
-`Naturalsorter::Sorter.sort(["c400", "b5", "a1"], true)`
+After the installation you can use it like this:
-The method head looks like this:
+`Naturalsorter::Sorter.sort(["a400", "a5", "a1"], true)`
-`Naturalsorter::Sorter.sort(array, caseinsesitive)`
+it will return the array ["a1", "a5", "a400"].
+If you have more advanced objects you want to sort, you should use the second method. Assume you have a Class User with 3 attributes: "firstname", "lastname", "age" and you want to sort an array of class Users by "firstname".
+`Naturalsorter::Sorter.sort_by_method(users, "firstname", true)`
+that's it!
-That's it.
@@ -7,11 +7,11 @@
it "c400b5a1 is a1b5c400" do
- Naturalsorter::Sorter.sort(["c400", "b5", "a1"], true).should eql(["a1", "b5", "c400"])
+ Naturalsorter::Sorter.sort(["a400", "a5", "a1"], true).should eql(["a1", "a5", "a400"])
it "c400b5a1 is a1b5c400" do
- Naturalsorter::Sorter.sort_by_method(["c400", "b5", "a1"], "to_s", true).should eql(["a1", "b5", "c400"])
+ Naturalsorter::Sorter.sort_by_method(["a400", "a5", "a1"], "to_s", true).should eql(["a1", "a5", "a400"])

0 comments on commit 0cb6a8e

Please sign in to comment.