Skip to content

Commit bdab624

Browse files
during colsort put missing values at bottom always (#91)
* during colsort put missing values at bottom always * Update variant_template.html --------- Co-authored-by: Jim Robinson <933148+jrobinso@users.noreply.github.com>
1 parent dcec933 commit bdab624

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

igv_reports/templates/variant_template.html

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,17 +273,26 @@
273273
return tr.children[idx].innerText || tr.children[idx].textContent;
274274
}
275275

276-
function comparer(idx, asc) {
276+
function comparer(idx, asc) {
277277
return function (a, b) {
278-
return function (v1, v2) {
278+
return function (v1, v2, asc) {
279279
// Special case for chromosome coloumn
280280
if (idx === 0 && v1.startsWith('chr') && v2.startsWith('chr')) {
281281
v1 = v1.substr(3);
282282
v2 = v2.substr(3);
283283
}
284+
// always put empty columns at end of table when sorting
285+
if (v1 == '' && v2 != '') { return 1; }
286+
if (v2 == '' && v1 != '') { return -1; }
287+
284288
var isNumber = v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2)
285-
return isNumber ? v1 - v2 : v1.toString().localeCompare(v2);
286-
}(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
289+
ret = isNumber ? v1 - v2 : v1.toString().localeCompare(v2);
290+
291+
// reverse ordering if not ascending order
292+
if (! asc) { ret = -1 * ret; }
293+
return(ret);
294+
295+
}(getCellValue(a, idx), getCellValue(b, idx), asc);
287296
}
288297
}
289298

0 commit comments

Comments
 (0)