From 95f07ea38a5b1dc88fbf1ec5e8cd0934f150b8b6 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 18 Aug 2012 03:40:42 -0700 Subject: [PATCH] Add stable-sort note to `_.sortBy` documentation. Former-commit-id: 17b9818baa6ff72ce5762ec8b3cc01bbac8725bb --- README.md | 1 + doc/README.md | 2 +- lodash.js | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 528760994..ac8cf774f 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ For more information check out these screencasts over Lo-Dash: * [_.indexOf](http://lodash.com/docs#indexOf) and [_.lastIndexOf](http://lodash.com/docs#lastIndexOf) accept a `fromIndex` argument * [_.merge](http://lodash.com/docs#merge) for a *"deep"* [_.extend](http://lodash.com/docs#extend) * [_.partial](http://lodash.com/docs#partial) for partial application without `this` binding + * [_.sortBy](http://lodash.com/docs#sortBy) performs a [stable](http://en.wikipedia.org/wiki/Sorting_algorithm#Stability) sort * [_.template](http://lodash.com/docs#template) utilizes [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier debugging * [_.where](http://lodash.com/docs#where) for filtering collections by contained properties * [_.zipObject](http://lodash.com/docs#zipObject) for composing objects diff --git a/doc/README.md b/doc/README.md index a082f6ebd..c35d931dd 100644 --- a/doc/README.md +++ b/doc/README.md @@ -2185,7 +2185,7 @@ _.some([null, 0, 'yes', false]); ### `_.sortBy(collection, callback [, thisArg])` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2280 "View in source") [Ⓣ][1] -Creates a new sorted array, sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. +Creates a new array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. diff --git a/lodash.js b/lodash.js index c8ec61c16..718a1849f 100644 --- a/lodash.js +++ b/lodash.js @@ -678,8 +678,8 @@ } /** - * Used by `sortBy` to compare transformed `collection` values, sorting them - * stabily in ascending order. + * Used by `sortBy` to compare transformed `collection` values, stable sorting + * them in ascending order. * * @private * @param {Object} a The object to compare to `b`. @@ -2253,9 +2253,9 @@ }); /** - * Creates a new sorted array, sorted in ascending order by the results of - * running each element of `collection` through a `callback`. The `callback` is - * bound to `thisArg` and invoked with 3 arguments; (value, index|key, collection). + * Creates a new array, stable sorted in ascending order by the results of + * running each element of `collection` through a `callback`. The `callback` + * is bound to `thisArg` and invoked with 3 arguments; (value, index|key, collection). * The `callback` argument may also be the name of a property to sort by (e.g. 'length'). * * @static