function transferSorter(plateCol, wellCol) {
	return (function(row1, row2) {
		var a = {}, b = {};
		a.id = row1[plateCol].trim().toLowerCase();
		b.id = row2[plateCol].trim().toLowerCase();
		// If plate ID is a number, convert from string to int/double:
		if(isNumber(a.id) && isNumber(b.id)) {
			a.id = parseNumber(a.id);
			b.id = parseNumber(b.id);
		} else {
			var p = /^\d\d\-\d{4,}$/;
			// If plate ID is a LIMS ID, convert from string to int:
			if(a.id.match(p) && b.id.match(p)) {
				a.id = parseNumber(a.id.replace("-",""));
				b.id = parseNumber(b.id.replace("-",""));
			} else {
				p = /^P\d{3,}P\d{1,2}$/i;
				// If plate ID is a project plate ID, e.g. P4568P2,
				// covert to int by removing 'P', e.g. 45682:
				if(a.id.match(p) && b.id.match(p)) {
					a.id = parseNumber(a.id.replace(/P/gi,""));
					b.id = parseNumber(b.id.replace(/P/gi,""));
				}
			}
		}
		// Sort alphabetically/numerically on plate ID, then source well:
		if(a.id !== b.id) {
			return (a.id < b.id) ? -1 : (a.id > b.id ? 1 : 0);
		} else {
			a.pos = convertCoordsRegExp(row1[wellCol]);
			b.pos = convertCoordsRegExp(row2[wellCol]);
			return (a.pos[1] === b.pos[1]) ? a.pos[0]-b.pos[0] : a.pos[1]-b.pos[1];
		}
	});
}
/*
 Sorts rows first alphabetically or numerically by the column given by plateCol,
 then by the well (col-then-row) in wellCol:
*/
Sorts rows first alphabetically or numerically by the column given by plateCol,
then by the well (col-then-row) in wellCol.
Sorts rows first alphabetically or numerically by the column given by plateCol then by the well ( col - then - row ) in wellCol .
function transferSorter(plateCol, wellCol) {
	return (function(row1, row2) {
		var a = {}, b = {};
		a.id = row1[plateCol].trim().toLowerCase();
		b.id = row2[plateCol].trim().toLowerCase();
		if(isNumber(a.id) && isNumber(b.id)) {
			a.id = parseNumber(a.id);
			b.id = parseNumber(b.id);
		} else {
			var p = /^\d\d\-\d{4,}$/;
			if(a.id.match(p) && b.id.match(p)) {
				a.id = parseNumber(a.id.replace("-",""));
				b.id = parseNumber(b.id.replace("-",""));
			} else {
				p = /^P\d{3,}P\d{1,2}$/i;
				if(a.id.match(p) && b.id.match(p)) {
					a.id = parseNumber(a.id.replace(/P/gi,""));
					b.id = parseNumber(b.id.replace(/P/gi,""));
				}
			}
		}
		if(a.id !== b.id) {
			return (a.id < b.id) ? -1 : (a.id > b.id ? 1 : 0);
		} else {
			a.pos = convertCoordsRegExp(row1[wellCol]);
			b.pos = convertCoordsRegExp(row2[wellCol]);
			return (a.pos[1] === b.pos[1]) ? a.pos[0]-b.pos[0] : a.pos[1]-b.pos[1];
		}
	});
}
function transferSorter ( plateCol , wellCol ) { return ( function ( row1 , row2 ) { var a = { } , b = { } ; a . id = row1 [ plateCol ] . trim ( ) . toLowerCase ( ) ; b . id = row2 [ plateCol ] . trim ( ) . toLowerCase ( ) ; if ( isNumber ( a . id ) && isNumber ( b . id ) ) { a . id = parseNumber ( a . id ) ; b . id = parseNumber ( b . id ) ; } else { var p = / ^\d\d\-\d{4,}$ / ; if ( a . id . match ( p ) && b . id . match ( p ) ) { a . id = parseNumber ( a . id . replace ( "-" , "" ) ) ; b . id = parseNumber ( b . id . replace ( "-" , "" ) ) ; } else { p = / ^P\d{3,}P\d{1,2}$ / i ; if ( a . id . match ( p ) && b . id . match ( p ) ) { a . id = parseNumber ( a . id . replace ( / P / gi , "" ) ) ; b . id = parseNumber ( b . id . replace ( / P / gi , "" ) ) ; } } } if ( a . id !== b . id ) { return ( a . id < b . id ) ? - 1 : ( a . id > b . id ? 1 : 0 ) ; } else { a . pos = convertCoordsRegExp ( row1 [ wellCol ] ) ; b . pos = convertCoordsRegExp ( row2 [ wellCol ] ) ; return ( a . pos [ 1 ] === b . pos [ 1 ] ) ? a . pos [ 0 ] - b . pos [ 0 ] : a . pos [ 1 ] - b . pos [ 1 ] ; } } ) ; }
Sorts rows first alphabetically or numerically by the column given by plateCol,
then by the well (col-then-row) in wellCol:
Sorts rows first alphabetically or numerically by the column given by plateCol then by the well ( col - then - row ) in wellCol :
// If plate ID is a number, convert from string to int/double: // If plate ID is a LIMS ID, convert from string to int: // If plate ID is a project plate ID, e.g. P4568P2, // covert to int by removing 'P', e.g. 45682: // Sort alphabetically/numerically on plate ID, then source well: