3.2.0

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
April 11,
Yes, that's a bug - thanks a lot for finding this!
Alex (ActiveWidgets)
April 11,
Alex - I just upgraded to 2.0.1 and noticed that this fix was not included.
CK
August 11,
Yes, somehow I got confused by this one - will be in 2.0.2

Alex (ActiveWidgets)
August 11,
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
August 13,

This topic is archived.

See also:


Back to support forum