JavaScript arrays may be manipulated with numerous built-in methods and properties. However to compare multiple depth items array and sort them out as wanted and properly, a technique that does not contain anu pre-existing methods may be the best and most elegant solution. This technique is presented in the example below where a list of four people is created, depending on the user's input and preference. The list of people may be sorted in three ways, by FIRST NAME, by SECOND NAME, or by AGE.

Example of an array comparison and sorting with JavaScript code


›› go to examples ››