Fossil SCM
Make table sorting (by clicking on column headers) stable. In other words, identical values in the column being sorted preserve their prior relative order. Patch suggested by Jacek Cała.
Commit
fe61f4958d1b8983cf051922d35648d63674508a
Parent
beaf897cb1ab47d…
1 file changed
+3
-2
+3
-2
| --- src/report.c | ||
| +++ src/report.c | ||
| @@ -999,27 +999,28 @@ | ||
| 999 | 999 | @ } |
| 1000 | 1000 | @ this.sortText = function(a,b) { |
| 1001 | 1001 | @ var i = thisObject.sortIndex; |
| 1002 | 1002 | @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase(); |
| 1003 | 1003 | @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase(); |
| 1004 | - @ if(aa==bb) return 0; | |
| 1004 | + @ if(aa==bb) return a.rowIndex-b.rowIndex; | |
| 1005 | 1005 | @ if(aa<bb) return -1; |
| 1006 | 1006 | @ return 1; |
| 1007 | 1007 | @ } |
| 1008 | 1008 | @ this.sortNumeric = function(a,b) { |
| 1009 | 1009 | @ var i = thisObject.sortIndex; |
| 1010 | 1010 | @ aa = parseFloat(a.cells[i].textContent); |
| 1011 | 1011 | @ if (isNaN(aa)) aa = 0; |
| 1012 | 1012 | @ bb = parseFloat(b.cells[i].textContent); |
| 1013 | 1013 | @ if (isNaN(bb)) bb = 0; |
| 1014 | + @ if(aa==bb) return a.rowIndex-b.rowIndex; | |
| 1014 | 1015 | @ return aa-bb; |
| 1015 | 1016 | @ } |
| 1016 | 1017 | @ this.sortKey = function(a,b) { |
| 1017 | 1018 | @ var i = thisObject.sortIndex; |
| 1018 | 1019 | @ aa = a.cells[i].getAttribute("data-sortkey"); |
| 1019 | 1020 | @ bb = b.cells[i].getAttribute("data-sortkey"); |
| 1020 | - @ if(aa==bb) return 0; | |
| 1021 | + @ if(aa==bb) return a.rowIndex-b.rowIndex; | |
| 1021 | 1022 | @ if(aa<bb) return -1; |
| 1022 | 1023 | @ return 1; |
| 1023 | 1024 | @ } |
| 1024 | 1025 | @ var x = tableEl.getElementsByTagName('thead'); |
| 1025 | 1026 | @ if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){ |
| 1026 | 1027 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -999,27 +999,28 @@ | |
| 999 | @ } |
| 1000 | @ this.sortText = function(a,b) { |
| 1001 | @ var i = thisObject.sortIndex; |
| 1002 | @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase(); |
| 1003 | @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase(); |
| 1004 | @ if(aa==bb) return 0; |
| 1005 | @ if(aa<bb) return -1; |
| 1006 | @ return 1; |
| 1007 | @ } |
| 1008 | @ this.sortNumeric = function(a,b) { |
| 1009 | @ var i = thisObject.sortIndex; |
| 1010 | @ aa = parseFloat(a.cells[i].textContent); |
| 1011 | @ if (isNaN(aa)) aa = 0; |
| 1012 | @ bb = parseFloat(b.cells[i].textContent); |
| 1013 | @ if (isNaN(bb)) bb = 0; |
| 1014 | @ return aa-bb; |
| 1015 | @ } |
| 1016 | @ this.sortKey = function(a,b) { |
| 1017 | @ var i = thisObject.sortIndex; |
| 1018 | @ aa = a.cells[i].getAttribute("data-sortkey"); |
| 1019 | @ bb = b.cells[i].getAttribute("data-sortkey"); |
| 1020 | @ if(aa==bb) return 0; |
| 1021 | @ if(aa<bb) return -1; |
| 1022 | @ return 1; |
| 1023 | @ } |
| 1024 | @ var x = tableEl.getElementsByTagName('thead'); |
| 1025 | @ if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){ |
| 1026 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -999,27 +999,28 @@ | |
| 999 | @ } |
| 1000 | @ this.sortText = function(a,b) { |
| 1001 | @ var i = thisObject.sortIndex; |
| 1002 | @ aa = a.cells[i].textContent.replace(/^\W+/,'').toLowerCase(); |
| 1003 | @ bb = b.cells[i].textContent.replace(/^\W+/,'').toLowerCase(); |
| 1004 | @ if(aa==bb) return a.rowIndex-b.rowIndex; |
| 1005 | @ if(aa<bb) return -1; |
| 1006 | @ return 1; |
| 1007 | @ } |
| 1008 | @ this.sortNumeric = function(a,b) { |
| 1009 | @ var i = thisObject.sortIndex; |
| 1010 | @ aa = parseFloat(a.cells[i].textContent); |
| 1011 | @ if (isNaN(aa)) aa = 0; |
| 1012 | @ bb = parseFloat(b.cells[i].textContent); |
| 1013 | @ if (isNaN(bb)) bb = 0; |
| 1014 | @ if(aa==bb) return a.rowIndex-b.rowIndex; |
| 1015 | @ return aa-bb; |
| 1016 | @ } |
| 1017 | @ this.sortKey = function(a,b) { |
| 1018 | @ var i = thisObject.sortIndex; |
| 1019 | @ aa = a.cells[i].getAttribute("data-sortkey"); |
| 1020 | @ bb = b.cells[i].getAttribute("data-sortkey"); |
| 1021 | @ if(aa==bb) return a.rowIndex-b.rowIndex; |
| 1022 | @ if(aa<bb) return -1; |
| 1023 | @ return 1; |
| 1024 | @ } |
| 1025 | @ var x = tableEl.getElementsByTagName('thead'); |
| 1026 | @ if(!(this.tbody && this.tbody[0].rows && this.tbody[0].rows.length>0)){ |
| 1027 |