@@ -12,29 +12,29 @@ const METRICS_SORTED_BY_COLOR = [
12
12
13
13
function getSortingFnByKey ( key ) {
14
14
if ( METRICS_SORTED_BY_CSS_UNIT . includes ( key ) ) {
15
- return cssUnitSort . sortFn
15
+ return ( a , b ) => cssUnitSort . sortFn ( a , b ) * - 1
16
16
}
17
17
18
- return ( a , b ) => {
19
- return caseInsensitiveCompare ( b , a )
18
+ if ( METRICS_SORTED_BY_COLOR . includes ( key ) ) {
19
+ return cssColorSort . sortFn
20
20
}
21
+
22
+ return ( a , b ) => caseInsensitiveCompare ( a , b )
21
23
}
22
24
23
25
function mergeLists ( listA , listB , key ) {
24
26
// Create a single list out of both lists that will take their
25
27
// unique values
26
- const merged = listA
27
- . concat ( listB )
28
- // Remove duplicate items
29
- . filter ( ( value , index , self ) => {
30
- return self . lastIndexOf ( value ) === index
31
- } )
32
- // Re-sort the items
33
- . sort ( getSortingFnByKey ( key ) )
34
- . reverse ( )
35
-
36
- // Until color-sorter supports a sortFn, we must sort the list at this place
37
- return METRICS_SORTED_BY_COLOR . includes ( key ) ? cssColorSort ( merged ) : merged
28
+ return (
29
+ listA
30
+ . concat ( listB )
31
+ // Remove duplicate items
32
+ . filter ( ( value , index , self ) => {
33
+ return self . lastIndexOf ( value ) === index
34
+ } )
35
+ // Re-sort the items
36
+ . sort ( getSortingFnByKey ( key ) )
37
+ )
38
38
}
39
39
40
40
function diffLists ( listA , listB , key ) {
0 commit comments