showing results for - "sort multidimensional array javascript"
Moritz
17 Apr 2016
1var arr = [[12, 'AAA'], [12, 'BBB'], [12, 'CCC'],[28, 'DDD'], [18, 'CCC'],[12, 'DDD'],[18, 'CCC'],[28, 'DDD'],[28, 'DDD'],[58, 'BBB'],[68, 'BBB'],[78, 'BBB']];
2
3arr.sort(function(a,b) {
4    return a[0]-b[0]
5});
Esparanza
21 Sep 2019
1let arr = [[12, 'AAA'], [12, 'BBB'], [12, 'CCC'],[28, 'DDD'], [18, 'CCC'],[12, 'DDD'],[18, 'CCC'],[28, 'DDD'],[28, 'DDD'],[58, 'BBB'],[68, 'BBB'],[78, 'BBB']];
2
3// sort by first column (numbers) using minus
4arr.sort((a, b) => a[0]-b[0]);
5/* [[12,"AAA"],[12,"BBB"],[12,"CCC"],[12,"DDD"],[18,"CCC"],[18,"CCC"],[28,"DDD"],[28,"DDD"],[28,"DDD"],[58,"BBB"],[68,"BBB"],[78,"BBB"]] */
6
7// sort by second column (letters) using localeCompare
8arr.sort((a, b) => a[1].localeCompare(b[1]));
9/* VM704:1 [[12,"AAA"],[12,"BBB"],[58,"BBB"],[68,"BBB"],[78,"BBB"],[12,"CCC"],[18,"CCC"],[18,"CCC"],[12,"DDD"],[28,"DDD"],[28,"DDD"],[28,"DDD"]] */
queries leading to this page
sort an array by 2 criteria jssort multiple arraysort 2d array javascriptjavascript sort 2 dimensional arrayd3 js sort 2d arraynodejs multidimensional array sortsort multidimensional array based on argument jsmultidimension array sort javascript not workinghow to sort 2d array in javascriptjavascript sort multidimensional array alphabeticallyjavascript array som on multidimensionaljavascript multidimensional sortinghow to sort an 2d array in angularsorting two dimensional array javascriptsort multidimensional array jssort array by column javascriptjavascript sort multidimensional array multiple columnssorting n dimensional array based on one value javascripthow to sort multidimensional dimensional array in javascriptsorting two dimensional arrays jsreverse sort multidimensional array jshow to sort by one variable in a two dimensional array javascriptsort multidimensional array by number javascriptsort multidimensional array javascriptjavascript sort multidimensional array object valuehow to sort twodimantion array and number in jssort javascript multidimensional array of optionssort multidimensional array javascriptjavascript array sort by first columnhow to sort multidimensional array in javascriptsort by columns in matrix jstypescript sort multidimensional arraysort a 2d array javascript from high to low valuesorting a two dimensional array in javascriptsort 2d array in javascriptjs sort multidimensional array by valuejavascript sort multidimensional array by columnsort matrix by column jsarray array orderby multidimensionaljavascript sort two dimensional array by valuehow to sort a multidimensional array in javascriptorder 2d array on vallue jssort two dimensional number array javascriptjavascript sort multidimensional array descendingsort in typescript multidimensional arraysoort 2d array of numbers jsmultidimensional array sort in javascriptjavascript set multidimensional arraydimensional number array javascript ordersort array multidimentional jscan i apply sort on multi dimensional array javascripttypescript sort number multidimensional arrayjs multi sort array of araysort multiple array jssort javascript multidimensional arraysort 2d array according to value in jstwo dimensional array sort in javascriptjavascript sort array by specific columnjavascript order multidimensional arraysort multidimensional array with length javascriptsort array 2 dimensional from min to max javascripthow to sort multidimensional array in jshow to sort a matrix in javascripmulti array order javascriptsort items in a 2d array javascriptsort a 2d array javascriptsort array multidimensional array by number javascriptsort named multidimensional array javascriptjavascript sorting a 2d arrayjavascript sort array multiple criteriaarray sort 2d array jsjavascript selection sort multidimensional arrayhow to sort a 2d array in javascriptjavascript sort multidimensional associative arrayhow to sort an array by two value value in javascriptsort matrix all column jshow to sort two dimensional array in javascriptjavascript multidimensional array sortsort array in node js with multidimensionalsort based on two value in array in jsorder by array in typescript multidimensionalsorting two dimensional array in javascriptjs array sort by columnjavascript array sortieren mehrdimensionalsort 2 dimensional array javascriptjavascript sort multidimensional array by keyjavascript sort 2d arrayjs multidimensional array sort by column descjavascript sort two dimensional arraysorting multidimensional array in javascriptsort multidimensional array js without sort functionjavascript 2d array rearrangesort multidimensional array based on integer jssorting multidimensional array javascriptjs sort 2d arrayjs sort multidimensional arraysort all column in multidimensional array javascriptnode sort nested arrayjavascript sort multidimensional array objectorder numbers in multiple array javascripthow to sort an multidimensional array in jssort multidimensional array by value jssort array 2 dimensional javascriptsort two dimentional array in javascriptmultidimensional array length sort in javascriptsort two d array javascripthow to sort a two dimensional array in javascriptsort 2d array jssorting single dimensional array in javascriptmultidimensional array javascript sortarray multidimensional sort jssort multidimensional array by first value javascriptsort all columns in matrix jssorting 2 dimensional array in javascriptsort two dimensional number array javascri 5btjavascript sort multidimensional arraysort array in javascript in two conditionssort data in multi dimensional array jsorder multidimensional array list with javascriptjs sort multi arraysort two dimensional array javascriptmulti array sort javascriptsort multidimensional array javascript