Sort separation of numbers and strings in a column
I'm trying to overwriting the sorting on a column that contains boths numbers and strings so that the strings always appear below the numbers regardless of sort direction. Unfortunately, I'm not having much luck getting it right.
This is what I have so far -
Can anyone spot what's wrong with the function?
This is what I have so far -
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)
Can anyone spot what's wrong with the function?
Anthony
September 25,