Ver Mensaje Individual
  #27 (permalink)  
Antiguo 14/12/2004, 08:39
kepawe
 
Fecha de Ingreso: agosto-2004
Mensajes: 157
Antigüedad: 19 años, 7 meses
Puntos: 5
Hola furoya y caricatos.

El código del método "spanish_sort" tiene un error. Posiciona la "o" antes que la "ñ", mando el script corregido.

<script language=JavaScript type=text/javascript>
<!--

Array.prototype.spanish_sort = function(){
//Creamos este array para copiar los elementos del array
var temp_array = new Array()
// Poblamos el array temp_array con los elementos de array queremos ordenar
for(var ctr = 0; ctr < this.length ; ctr++){
temp_array[ctr] = this[ctr]
// Sustituimos las vocales acentuadas y la ñ (mininusculas)
temp_array[ctr] = temp_array[ctr].toString().replace(/á|é|í|ó|ú|ñ/g,function (str,offset,s) {
str =str=="á"?"ab":str=="é"?"ef":str=="í"?"ij":str=="ó "?"op":str=="ú"?"uv":str=="ñ"?"n~":"n~"
return (str)
}
)
//Sustituimos las vocales acentuadas y la ñ (mayusculas)
temp_array[ctr] = temp_array[ctr].toString().replace(/Á|É|Í|Ó|Ú|Ñ/g,function (str,offset,s) {
str =str=="Á"?"AB":str=="É"?"EF":str=="Í"?"IJ":str=="Ó "?"OP":str=="Ú"?"UV":str=="Ñ"?"N~":"N~"
return (str)
}
)
}
// ordenamos alfabeticamente
var sc = true
var lg = temp_array.length
while(sc &&(--lg > 0)){
sc= false
for(var i =1; i<= lg; i++){
if(temp_array[i-1] > temp_array[i]){
tmp = temp_array[i -1]
tmpo = this[i-1]
temp_array[i-1] = temp_array[i]
this[i-1] = this[i]
temp_array[i] = tmp
this[i] = tmpo
sc= true
}

}

}

}



//-->
</script>

Saludos