Check if a list is sorted in javascript using underscore.js -


in javascript (underscore) , how test whether list of numbers sorted or not?

you can use _.every check whether elements in order:

_.every(arr, function(value, index, array) {   // either first element, or otherwise element should    // not smaller previous element.   // spec requires string conversion   return index === 0 || string(array[index - 1]) <= string(value); }); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -