blob: df1b2a3789145057508d5d9451d51bfd402f1ef4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# Sort by Attributes
## Tags
* assigned: zachs, fredm
* type: feature-request, feature request
* priority: high
* status: closed
* 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.
### Fixed
With commit https://github.com/genenetwork/genenetwork2/commit/4c4d91d03a873969315727918206097a0d89bb19
The sort functions in search_results.js were moved into table_functions.js so they could be used by more pages.
In this case, the trait page needed access so that the case attribute columns could be sorted such that NA/NULL value
are always at the bottom.
|