|
110 | 110 | changed.length && dispatch('facetSelect', changed); |
111 | 111 | }; |
112 | 112 |
|
113 | | - // Keeping the sorting function, but stays unused for now |
114 | 113 | const sortOptions = () => { |
115 | | - // Sort facets in a descending order if count exits, or sort alphabetically |
| 114 | + // Sort facets in a descending order if count exits |
116 | 115 | Object.keys(selected).forEach((group) => { |
117 | 116 | const checked = Object.keys(selected[group].children) |
118 | 117 | .filter((item) => selected[group].children[item].selected) |
|
121 | 120 | if (a.count != undefined && b.count != undefined) { |
122 | 121 | return b.count - a.count; |
123 | 122 | } |
124 | | - return a.displayName.localeCompare(b.displayName); |
| 123 | + return 0; |
125 | 124 | }) |
126 | 125 | .map((item) => item.name); |
127 | 126 |
|
128 | | - const unchecked = Object.keys(selected[group].children).filter( |
129 | | - (item) => !checked.includes(item) |
130 | | - ); |
| 127 | + const unchecked = Object.keys(selected[group].children) |
| 128 | + .filter((item) => !checked.includes(item)) |
| 129 | + .map((item) => selected[group].children[item]) |
| 130 | + .sort((a, b) => { |
| 131 | + if (a.count != undefined && b.count != undefined) { |
| 132 | + return b.count - a.count; |
| 133 | + } |
| 134 | + return 0; |
| 135 | + }) |
| 136 | + .map((item) => item.name); |
131 | 137 |
|
132 | 138 | const groupIndex = displayedGroups.findIndex((g) => g.name === group); |
133 | 139 |
|
|
172 | 178 | }); |
173 | 179 |
|
174 | 180 | $: displayedGroups = structuredClone($groups); |
175 | | - $: selectedItems, mapSelected('items'); // sortOptions(); // Sorting is not used for now |
| 181 | + $: selectedItems, mapSelected('items'), sortOptions(); |
176 | 182 | $: selectedGroups, mapSelected('groups'); |
177 | 183 | </script> |
178 | 184 |
|
|
0 commit comments