lib/polymorphic.js
function prioritize(list, arg) {
		return list.sort(function(a, b) {
			var typing = function(item, index) {
					return +(item.type === type(arg[index], true));
				};

			//  if the calculated specificity is not equal it has precedence
			if (a.specificity !== b.specificity) {
				//  the shortest specificity OR ELSE the highest specificity wins
				return a.specificity.length - b.specificity.length || b.specificity - a.specificity;
			}

			//  if the specificity is equal, we want to prioritize on the more explicit types
			return b.arguments.map(typing).join('') - a.arguments.map(typing).join('');
		});
	}
function prioritize(list, arg) {
		return list.sort(function(a, b) {
			var typing = function(item, index) {
					return +(item.type === type(arg[index], true));
				};

			//  if the calculated specificity is not equal it has precedence
			if (a.specificity !== b.specificity) {
				//  the shortest specificity OR ELSE the highest specificity wins
				return a.specificity.length - b.specificity.length || b.specificity - a.specificity;
			}

			//  if the specificity is equal, we want to prioritize on the more explicit types
			return b.arguments.map(typing).join('') - a.arguments.map(typing).join('');
		});
	}
function prioritize ( list , arg ) { return list . sort ( function ( a , b ) { var typing = function ( item , index ) { return + ( item . type === type ( arg [ index ] , true ) ) ; } ; //  if the calculated specificity is not equal it has precedence if ( a . specificity !== b . specificity ) { //  the shortest specificity OR ELSE the highest specificity wins return a . specificity . length - b . specificity . length || b . specificity - a . specificity ; } //  if the specificity is equal, we want to prioritize on the more explicit types return b . arguments . map ( typing ) . join ( '' ) - a . arguments . map ( typing ) . join ( '' ) ; } ) ; }
Prioritize the items in the list
@name    prepare
@access  internal
@param   array  candidates
@param   array  arguments
@return  array  prioritized candidates
@note    the list should contain pre-mapped items (as it works on specificity mostly)
Prioritize the items in the list