JavaScript - Sort And Search

javascript

Sophisticated Sorting in JavaScript
https://www.sitepoint.com/sort-an-array-of-objects-in-javascript/
JavaScript sort
Revised JavaScript Dictionary Search
Optimizing search functionality with large javascript arrays
Quick Tip: Object Indexing vs. Array Collection
Dictionary Lookups in JavaScript
http://www.javascriptkit.com/javatutors/arraysort.shtml
http://net.tutsplus.com/tutorials/javascript-ajax/sorting-values-with-javascript/

// Sort an array of strings ascending and case-insensitive:
clone.sort((a,b) => {
    return a.toLowerCase().localeCompare(b.toLowerCase());
})

// To sort an array of numbers in ascending order:
var numbers = [8,5];
numbers.sort(function(a, b)
{
    return a - b;    
});
console.log(numbers); // produces [5,8]

// To sort an array of numbers in descending order:
var numbers = [5,8];
numbers.sort(function(a, b)
{
    return b - a;    
});
console.log(numbers); // produces [8,5]
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License