From 6460ff889bdeac659f1e7aa0c4d1e9e7d5030001 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 31 May 2024 14:36:30 -0500 Subject: GN2: New issue: Sort data by attributes. --- issues/genenetwork2/sort-by-attributes.gmi | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 issues/genenetwork2/sort-by-attributes.gmi (limited to 'issues') diff --git a/issues/genenetwork2/sort-by-attributes.gmi b/issues/genenetwork2/sort-by-attributes.gmi new file mode 100644 index 0000000..68ef2ce --- /dev/null +++ b/issues/genenetwork2/sort-by-attributes.gmi @@ -0,0 +1,40 @@ +# Sort by Attributes + +## Tags + +* assigned: zachs, fredm +* type: feature-request, feature request +* priority: high +* status: open +* keywords: genenetwork2, sorting, attributes + +## Description + +From the email: + + +> This trait: +> +> https://genenetwork.org/show_trait?trait_id=L2229-L8228&dataset=Duke_UTHSC_ConnStrgROIs4zlog2_0524 +> +> I want to sort by the attribute Age, from youngest to oldest but all of the NULL values are treated as the lowest value. I would much prefer sorting to ignore these empty fields.. + +Javascript is weird, and we'd have to do something like the following to sort with ages: + +``` +myarr.toSorted((a, b) => { + if(a == null) {/*isNumber(null) = true*/ + return 1; + } + if(b == null) { + return -1; + } + if(isNumber(a) && isNumber(b)) { + return a - b; + } +}); +``` + +to ensure that null values always come last. + +Mixed lists are going to have to be sorted in alphabetical order, I guess, while still ensuring nulls end up last with something like the above. -- cgit v1.2.3