Edit in JSFiddle

var makeFnSortArray = ( ...criteria ) => {

  var order = criteria.reduce( ( o, item, i) => {
    o[item] = i+1;
    return o;
  }, {})

  return (a, b) => {
    if ( (order[b] && !order[a]) || order[a] > order[b] ) return 1;
    if ( (order[a] && !order[b]) || (order[a] < order[b]) ) return -1;
    if ( a > b ) return 1;
    if ( a < b ) return -1;
    return 0;
  }
}

/* criteria: 'foto','mapa','audio','video','interactivo' */
{
  let fnOrderMedia = makeFnSortArray('foto','mapa','audio','video','interactivo');

  console.log( ['mapa', 'foto'].sort(fnOrderMedia).join(',') === 'foto,mapa' );
  console.log( ['audio', 'mapa', 'foto'].sort(fnOrderMedia).join(',') === 'foto,mapa,audio' );
  console.log( ['audio', 'foto', 'interactivo', 'mapa', 'video'].sort(fnOrderMedia).join(',') === 'foto,mapa,audio,video,interactivo' );
  console.log( ['mapa','bbb','aaa', 'ccc','foto'].sort(fnOrderMedia).join(',') === 'foto,mapa,aaa,bbb,ccc' );
}

/* criteria: 'video','mapa' */
{
  let fnOrderMedia2 = makeFnSortArray('video','mapa','interactivo','foto','audio');

  console.log( ['mapa', 'foto'].sort(fnOrderMedia2).join(',') === 'mapa,foto' );
  console.log( ['audio', 'mapa', 'foto'].sort(fnOrderMedia2).join(',') === 'mapa,foto,audio' );
  console.log( ['audio', 'foto', 'interactivo', 'mapa', 'video'].sort(fnOrderMedia2).join(',') === 'video,mapa,interactivo,foto,audio' );
}

/* criteria: 'spain','portugal','france' */
{
  let fnOrderCountries = makeFnSortArray('spain','portugal','france');

  console.log( ['germany', 'france', 'italy', 'spain', 'england'].sort(fnOrderCountries).join(',') === 'spain,france,england,germany,italy' );
}