function isArray(item) {return typeof(item)=='object' && item!=null;}

function MultiSortClass(opt)
{
var root  = this;
this.opt  = {};
this.func = {};
this.func.cmpDate = function (a,b)
	{
	return (a[3]>b[3] ? 1 : (a[3]<b[3] ? -1 : 0));
	}
this.func.cmpStrAsc = function (a,b)
	{
	return a.length>b.length && a>b ? 1 : (a==b ? 0 : -1);
	}
this.func.cmpStrDesc = function (b,a)
	{
	return a.length>b.length && a>b ? 1 : (a==b ? 0 : -1);
	}
this.func.cmpNumAsc = function (a,b)
	{
	return a>b ? 1 : (a==b ? 0 : -1);
	}
this.func.cmpNumDesc = function (b,a)
	{
	return a>b ? 1 : (a==b ? 0 : -1);
	}
this.cmp = function (a,b)
	{
	var out, i;
	out = 0;
	for (i in root.opt)
		{
		out = root.opt[i](a[i],b[i]);
		if (out!=0)
			{
			return out;
			}
		}
	return out;
	}
this.func.cbUpper = function(match,content0,content1)
	{
	return content0.toUpperCase() + content1.toLowerCase();
	}
this.setOpt = function (opt)
	{
	var row, i, i_end, func;
	root.opt = {};
	if (!(isExist(opt) && isArray(opt)))
		{
		return;
		}
	i_end = opt.length;
	for (i=0;i<i_end;i++)	// convert {col:2,cmp:'num',order:'asc'} => root.func.cmpNumAsc
		{
//alert('a'+i)
		row = opt[i];
		row.cmp   = row.cmp.replace(/^([a-z])([a-z]+)$/i,root.func.cbUpper);
		row.order = row.order.replace(/^([a-z])([a-z]+)$/i,root.func.cbUpper);
		func      = 'cmp'+row.cmp+row.order;
//alert(func)
		if (isFunction(root.func[func]))
			{
//alert('b'+i)
			root.opt[row.col] = root.func[func];
			}
		}
	}
this.setOpt(opt);
}
/*
var arr = [
['a', 1, 11],
['a', 0, 10],
['a', 1, 9],
['a', 0, 8],
]
var x;
x = new MultiSortClass([
		{col:1,cmp:'num',order:'asc'},
		{col:2,cmp:'num',order:'asc'}
		]);
arr.sort(x.cmp)
str = '';
for (i=0;i<arr.length;i++)
	{
	str += arr[i].join(', ') + ' \n '
	}
alert(str)
*/
