Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

sortedIndex documentation #1001

Merged
merged 1 commit into from

2 participants

@burin

Adding note about using strings as iterators and example usage.

@burin burin sortedIndex documentation
Adding note about using strings as iterators and an example.
3764e8f
@jashkenas jashkenas merged commit 656dcdd into jashkenas:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 6, 2013
  1. @burin

    sortedIndex documentation

    burin authored
    Adding note about using strings as iterators and an example.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 index.html
View
5 index.html
@@ -904,10 +904,15 @@ <h2 id="arrays">Array Functions</h2>
<i>should</i> be inserted into the <b>list</b> in order to maintain the <b>list</b>'s
sorted order. If an <b>iterator</b> is passed, it will be used to compute
the sort ranking of each value, including the <b>value</b> you pass.
+ Iterator may also be the string name of the property to sort by (eg. <tt>length</tt>).
</p>
<pre>
_.sortedIndex([10, 20, 30, 40, 50], 35);
=&gt; 3
+
+var stooges = [{name : 'moe', age : 40}, {name : 'larry', age : 50}, {name : 'curly', age : 60}];
+_.sortedIndex(stooges, {name: 'jill', age: 55}, 'age');
+=&gt; 2
</pre>
<p id="range">
Something went wrong with that request. Please try again.