var SpecialSort = AW.Formats.Number.subclass()
...
SpecialSort.create = function()
{
var obj = this.prototype
obj.comparator = function(values, greater, less, equal, error)
{
return function(i, j)
{
try
{
var a = values[i], b = values[j]
if (typeof(a) == "number" && typeof(b) == "number")
{
if (a > b) {return greater}
if (a < b) {return less}
return equal(i, j)
}
if (typeof(a) == "string" && typeof(b) == "string")
return equal(i, j)
if (typeof(a) == "number")
{
return greater == 1 ? greater : less
}
return greater == 1 ? less : greater
}
catch(e){return error(i, j, e)}
}
}
}
...
obj.setCellFormat(new SpecialSort, 7)
var SpecialSort = AW.Formats.String.subclass()
...
SpecialSort.create = function()
{
var obj = this.prototype
obj.comparator = function(values, greater, less, equal, error)
{
return function(i, j)
{
try
{
var a = values[i], b = values[j]
if (a.indexOf("n/a") < 0 && b.indexOf("n/a") < 0)
{
if (a > b) {return greater}
if (a < b) {return less}
return equal(i, j)
}
if (a.indexOf("n/a") == 0)
{
return greater == 1 ? greater : less
}
return greater == 1 ? less : greater
}
catch(e){return error(i, j, e)}
}
}
}
...
obj.setCellFormat(new SpecialSort, 7)
This topic is archived.