JSFiddle - React, Tailwind, and code Playground

JavaScript

function transform() {
	var arr = [].slice.call(arguments);
	return arr[0].map(function(a, i) {
		return arr.map(function(aa, j) {
			return aa[i];
		});
	});
}

var hdnFromValues = [0,   16,  12,   0,  14,  18,  15];
var hdnToValues   = [0,   17,  13,   0,  15,  19,  16];
var hdnSPIDs      = [11,  12,  13,  14,   0,   0,   0];
var hdnFlag       = ['D', 'E', 'E', 'D', 'A', 'A', 'A'];

transformed = transform(hdnFromValues, hdnToValues, hdnSPIDs, hdnFlag);

//console.log(transformed);

/*** Copyright 2013 Teun Duynstee Licensed under the Apache License, Version 2.0 ***/
firstBy=(function(){function e(f){f.thenBy=t;return f}function t(y,x){x=this;return e(function(a,b){return x(a,b)||y(a,b)})}return e})();

	var result = transform(hdnFromValues, hdnToValues, hdnSPIDs, hdnFlag).sort(
		firstBy(function(a, b) { return a[0] - b[0]; })//numeric
		.thenBy(function(a, b) { return a[1] - b[1]; })//numeric
		.thenBy(function(a, b) { return a[2] - b[2]; })//numeric
		.thenBy(function(a, b) { return (a[3] < b[3]) ? -1 : (a[3] > b[3]) ? 1 : 0; })//alphabetic
	);

console.log(result);