:: Forum >>

sort problem with equal values

The 2nd column in the following grid does not sort correctly in IE, I think because of a bug in AW.Grid.Controllers.Sort.

<script>
var obj = new AW.UI.Grid;
var rowdata = [
    [3, 2],
    [2, 1],
    [1, 2]
];
obj.setRowCount(3);
obj.setColumnCount(2);
obj.setCellText(function(col,row){return "value[" + row + ","
+ col + "]=" + rowdata[row][col];});
obj.setCellValue(function(col,row){return rowdata[row][col];});
document.write(obj);
</script>


The sort problem can be fixed by calling obj.setCellFormat(number, 1). But I think the real fix is to AW.Grid.Controllers.Sort, below:

else if ("".localeCompare) {
        return function(i, j){
            try {
                var a = values[i], b = values[j], x, y;
                if (typeof(a) != typeof(b)){
                    x = types[typeof(a)];
                    y = types[typeof(b)];
                    if (x > y) {return greater}
                    if (x < y) {return less}
                } else if (typeof(a)=="number"){
                    if (a > b) {return greater}
                    if (a < b) {return less}
    // Next line is new !!
                    return equal(i,j);
                } else ...
CK
Tuesday, April 11, 2006
Yes, that's a bug - thanks a lot for finding this!
Alex (ActiveWidgets)
Tuesday, April 11, 2006
Alex - I just upgraded to 2.0.1 and noticed that this fix was not included.
CK
Friday, August 11, 2006
Yes, somehow I got confused by this one - will be in 2.0.2

Alex (ActiveWidgets)
Friday, August 11, 2006
Hi Alex

Is the sorting algo aw is using is mergesort ?I have also seen that is occurs because mergesort is Unstable sort and quicksort is stable kind of sort.

Thanks
Vikramaditya Garg
Vikramaditya Garg
Sunday, August 13, 2006

This topic is archived.


Back to support forum

Forum search