Commit 4b4da239 authored by Mike Hibler's avatar Mike Hibler

Make sorttable_alpha case-insensitive and use stable sort.

The former ensures that we get the same behavior as when the same
sorted output is produced using "order by" in mysql. I added a
sortable_alpha_cs that we can use for a column should we discover
a case where we really want a case-sensitive sort.

The latter ensures that a user can at least manually do a multi-column
sort (e.g., the equiv of "order by state,eid" when displaying experiments
by clicking on the eid column and then on the state column).
parent e8592249
......@@ -83,7 +83,7 @@ sorttable = {
for (var i=0; i<headrow.length; i++) {
// manually override the type with a sorttable_type attribute
if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
mtch = headrow[i].className.match(/\bsorttable_([a-z0-9_]+)\b/);
if (mtch) { override = mtch[1]; }
if (mtch && typeof sorttable["sort_"+override] == 'function') {
headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
......@@ -152,9 +152,9 @@ sorttable = {
row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];
}
/* If you want a stable sort, uncomment the following line */
//sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
/* and comment out this one */
row_array.sort(this.sorttable_sortfunction);
// row_array.sort(this.sorttable_sortfunction);
tb = this.sorttable_tbody;
for (var j=0; j<row_array.length; j++) {
......@@ -269,11 +269,16 @@ sorttable = {
if (isNaN(bb)) bb = 0;
return aa-bb;
},
sort_alpha: function(a,b) {
sort_alpha_cs: function(a,b) {
if (a[0]==b[0]) return 0;
if (a[0]<b[0]) return -1;
return 1;
},
sort_alpha: function(a,b) {
if (a[0].toLowerCase()==b[0].toLowerCase()) return 0;
if (a[0].toLowerCase()<b[0].toLowerCase()) return -1;
return 1;
},
sort_ddmm: function(a,b) {
mtch = a[0].match(sorttable.DATE_RE);
y = mtch[3]; m = mtch[2]; d = mtch[1];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment