function rootScript( hits ) {
	var sortingFn = function( a, b ) {
		a.custom_ranking = a.custom_ranking || 0;
		b.custom_ranking = b.custom_ranking || 0;

		if ( a.custom_ranking === b.custom_ranking ) return a.index - b.index;
		if ( a.custom_ranking > b.custom_ranking ) return -1;
		if ( a.custom_ranking < b.custom_ranking ) return 1;
	};

	return hits
		.filter( function( h ) {
			return !h.tags.includes( 'api' );
		} )
		.slice( 0, 10 )
		.map( function( item, idx ) {
			item.index = idx;
			return item;
		} )
		.sort( sortingFn );
}
