/*  Array:: Multi dimension array sorting.
	Example:
var DVD = [
['DVD Title 2','label2','releasedate2','details2'],
['DVD Title 1','label1','releasedate1','details1'],
['DVD Title n','labeln','releasedaten','detailsn'],
['DVD Title a','labela','releasedatea','detailsa']
];

alert(DVD.multiSort(1)); // SORTS BY LABEL \\;
alert(DVD.multiSort(2)); // SORTS BY RELEASE DATE \\;
ORDER WILL NOT CHANGE.   also, it iwll handle number sorting
*/
Array.prototype.multiSort = function(index, asc){ 
	if (index == undefined || index == null) index = 0;
	Array.prototype.multiSortIndex = index;
	if (asc == undefined || asc == null)
	{
		asc = true;
	} 
	
	if (asc)
	{
		return this.sort( function(a,b){
				if(isFinite(Number(a[Array.prototype.multiSortIndex])) && isFinite(Number(b[Array.prototype.multiSortIndex])))
				{
					return a[Array.prototype.multiSortIndex]- b[Array.prototype.multiSortIndex];
				} else
				{
					if (a[Array.prototype.multiSortIndex]<b[Array.prototype.multiSortIndex]) return -1;
					if (a[Array.prototype.multiSortIndex]>b[Array.prototype.multiSortIndex]) return 1;
					return 0;
				}
			}
		);
	} else
	{
		return this.sort( function(a,b){
				if(isFinite(Number(a[Array.prototype.multiSortIndex])) && isFinite(Number(b[Array.prototype.multiSortIndex])))
				{
					return b[Array.prototype.multiSortIndex]- a[Array.prototype.multiSortIndex];
				} else
				{
					if (a[Array.prototype.multiSortIndex]>b[Array.prototype.multiSortIndex]) return -1;
					if (a[Array.prototype.multiSortIndex]<b[Array.prototype.multiSortIndex]) return 1;
					return 0;
				}
			}
		);
	}
}

/*	Array:: Numeric Sorting
	Example:
var tmp = [5,9,12,18,56,1,10,42,30,7,97,53,33,35,27];    tmp=tmp.sortNum(); 
// returns 1,5,7,9,10,12,18,27,30,33,35,42,53,56,97 
*/
Array.prototype.sortNum = function() {   
	return this.sort( function (a,b) { return a-b; } );
}