index.js
// Function for returning a dynamic sorting function

Function for returning a dynamic sorting function
Function for returning a dynamic sorting function
function splitsSortBy(sort) {
	return function(a, b) {
		a = a[1];
		b = b[1];
		switch (sort) {
			case "ByName":
				a = a.name.toLowerCase();
				b = b.name.toLowerCase();
			break;
			case "ByCategory":
				a = a.category.toLowerCase();
				b = b.category.toLowerCase();
			break;
			case "ByTime":
				a = a.pb[0];
				b = b.pb[0];
			break;
		}
		if (a < b) {
			return -1;
		}
		if (a > b) {
			return 1;
		}
		return 0;
	};
}
function splitsSortBy ( sort ) { return function ( a , b ) { a = a [ 1 ] ; b = b [ 1 ] ; switch ( sort ) { case "ByName" : a = a . name . toLowerCase ( ) ; b = b . name . toLowerCase ( ) ; break ; case "ByCategory" : a = a . category . toLowerCase ( ) ; b = b . category . toLowerCase ( ) ; break ; case "ByTime" : a = a . pb [ 0 ] ; b = b . pb [ 0 ] ; break ; } if ( a < b ) { return - 1 ; } if ( a > b ) { return 1 ; } return 0 ; } ; }
Function for returning a dynamic sorting function
Function for returning a dynamic sorting function
// Simplifying the variables
