Lodash.js – sortedIndex() function
A simple Lodash.js example of the sortedIndex() function, which tells you on which index of the array the provided value should belong, according to the ascending of values.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="Tizen Angular.js example"/>
<title>Tizen lodash.js example</title>
<script src="js/lodash.min.js"></script>
</head>
<body>
<div id="first">
</div>
<br>
<div id="second">
</div>
<script>
var firstDiv = document.getElementById('first');
var secondDiv = document.getElementById('second');
var firstValue = [1,2,6,14,23,134];
firstDiv.innerHTML = "To the array of " + firstValue + " we want to put the value of 16 in the proper index...";
var result = _.sortedIndex(firstValue,16);
secondDiv.innerHTML = "...the value fits in to the index: " + result;
</script>
</body>
</html>