Site logo

Sorting

Sorting functions (from the SortParagraphs script)

function mySort(a, b){
	a = a.toLowerCase();
	b = b.toLowerCase();
	if(a > b){
		return 1;
	}
	if(a < b){
		return -1;
	}
	return 0;
}

function mySortIgnoringSpaces(a, b){
	var myRegExp = /\s/gi;
	a = a.toLowerCase().replace(myRegExp, "");
	b = b.toLowerCase().replace(myRegExp, "");
	if(a > b){
		return 1;
	}
	if(a < b){
		return -1;
	}
	return 0;
}

function myReverseSort(a, b){
	a = a.toLowerCase();
	b = b.toLowerCase();
	if(a > b){
		return -1;
	}
	if(a < b){
		return 1;
	}
	return 0;
}

function myReverseSortIgnoringSpaces(a, b){
	var myRegExp = /\s/gi;
	a = a.toLowerCase().replace(myRegExp, "");
	b = b.toLowerCase().replace(myRegExp, "");
	if(a > b){
		return -1;
	}
	if(a < b){
		return 1;
	}
	return 0;
}

Sort objects by geometric bounds function

Sort file names function for Mac (workaround for a Mac OSx bug)

Sorting two arrays according to one