javascript sort multidimensional array

Solutions on MaxInterview for javascript sort multidimensional array by the best coders in the world

showing results for - "javascript sort multidimensional array"
Théodore
12 Jan 2019
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});
Alice
18 Nov 2017
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 a 2d array javascriptsort two d array javascriptsoort 2d array of numbers jssorting two dimensional array in javascripthow to sort a matrix in javascripmultidimensional array sort in javascriptsort multidimensional array by value jssort 2d array in javascripthow to sort a two dimensional array in javascriptsort all column in multidimensional array javascripthow to sort an 2d array in angularsort array in javascript in two conditionsmultidimensional array javascript sortmulti array sort javascriptsort two dimensional array javascriptsorting n dimensional array based on one value javascriptsorting a two dimensional array in javascripthow to sort two dimensional array in javascriptsort matrix by column jssorting multidimensional array javascriptsort 2 dimensional array javascriptjavascript sort two dimensional arraysort items in a 2d array javascriptjavascript multidimensional sortingsort multidimensional array jssort multiple array jssort array by column javascriptsort an array by 2 criteria jsd3 js sort 2d arrayhow to sort a 2d array in javascriptsort 2d array jsjavascript array sort by first columnhow to sort 2d array in javascriptsort javascript multidimensional arrayjavascript sort multidimensional array object valuetypescript sort multidimensional arrayhow to sort multidimensional array in javascriptsort matrix all column jssorting single dimensional array in javascriptsort array in node js with multidimensionaljavascript order multidimensional arrayjavascript 2d array rearrangesort data in multi dimensional array jssorting two dimensional arrays jssort multiple arrayjavascript sort multidimensional array by keyhow to sort by one variable in a two dimensional array javascriptjs sort multidimensional arraymultidimension array sort javascript not workingsort multidimensional array by first value javascriptorder numbers in multiple array javascriptjavascript sort two dimensional array by valuejavascript sort multidimensional associative arrayjavascript sort array by specific columnmulti array order javascriptsort 2d array javascriptjs array sort by columnsort in typescript multidimensional arrayjavascript sort multidimensional arrayjavascript multidimensional array sortorder by array in typescript multidimensionaljavascript sort 2 dimensional arrayarray sort 2d array jsjavascript sort multidimensional array alphabeticallysort javascript multidimensional array of optionsmultidimensional array length sort in javascriptorder multidimensional array list with javascriptsort array multidimensional array by number javascriptsort all columns in matrix jsjavascript array som on multidimensionalsort multidimensional array with length javascriptsort 2d array according to value in jsarray multidimensional sort jsjs sort multi arrayjavascript set multidimensional arrayjavascript sort multidimensional array objectjavascript sort multidimensional array by columnsort two dimensional number array javascri 5btjavascript sort 2d arraycan i apply sort on multi dimensional array javascriptsort multidimensional array based on integer jssorting 2 dimensional array in javascriptorder 2d array on vallue jsjavascript sorting a 2d arraysort array multidimentional jssort multidimensional array javascriptsort multidimensional array by number javascriptsorting multidimensional array in javascripthow to sort multidimensional dimensional array in javascriptsort by columns in matrix jssort multidimensional array js without sort functionjs sort 2d arraysort multidimensional array based on argument jsreverse sort multidimensional array jstwo dimensional array sort in javascripthow to sort an multidimensional array in jsnodejs multidimensional array sortsort multidimensional array javascriptjavascript sort multidimensional array descendingtypescript sort number multidimensional arraynode sort nested arraysort named multidimensional array javascriptsort a 2d array javascript from high to low valuejs multidimensional array sort by column descjavascript array sortieren mehrdimensionalsort array 2 dimensional from min to max javascripthow to sort a multidimensional array in javascriptsorting two dimensional array javascriptsort array 2 dimensional javascriptjavascript sort multidimensional array