Skip to content

Commit

Permalink
sort facet values if they are numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
erral committed Mar 10, 2024
1 parent 16ffad6 commit fe9363e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/volto/news/5864.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correctly sort facet values if they are numbers @erral
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ const Facets = (props) => {
);

choices = choices.sort((a, b) =>
a.label.localeCompare(b.label, 'en', { sensitivity: 'base' }),
typeof a.label === 'string' && typeof b.label === 'string'
? a.label.localeCompare(b.label, 'en', { sensitivity: 'base' })
: typeof a.label === 'number' && typeof b.label == 'number'
? a - b
: 0,
);

const isMulti = facetSettings.multiple;
Expand Down

0 comments on commit fe9363e

Please sign in to comment.