Diferencia entre revisiones de «Módulo:Tablas»

Deshecha la edición 90799132 de Juan Mayordomo (disc.)
Sin resumen de edición
Línea 132: Línea 132:
end
end


function z.ordenar(tabla, funcion)
function z.ordenarFuncion(tabla, funcion)
local funcionInestable = funcion
local funcionInestable = funcion
Línea 146: Línea 146:
  end
  end
    end)
    end)
end
function z.ordenar(tabla, criterio)
if type(criterio) == 'table' then
z.ordenarFuncion(tabla,
function(a,b)
for i,campo in ipairs(criterio) do
if a[campo] < b[campo] then return true
elseif a[campo] > b[campo] then return false
end
end
  return false -- Todos los valores son iguales
end
)
else
z.ordenarFuncion(tabla, criterio)
end
end
end
   
   
return z
return z