Skip to content

Commit

Permalink
[upd] Move sort of questions by label to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklim committed Jul 1, 2020
1 parent 15bf18d commit cd44d39
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/components/Question.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ export default class Question extends React.Component {
}

// sort by label
question[Constants.HAS_SUBQUESTION].sort(
JsonLdObjectUtils.getCompareLocalizedLabelFunction(this.context.options.intl)
);
JsonLdObjectUtils.orderByLocalizedLabels(question[Constants.HAS_SUBQUESTION], this.context.options.intl);

// sort by property
JsonLdObjectUtils.orderPreservingToplogicalSort(
Expand Down
4 changes: 4 additions & 0 deletions src/util/JsonLdObjectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,8 @@ export default class JsonLdObjectUtils {
return 0;
};
}

static orderByLocalizedLabels(data, intl) {
return data.sort(JsonLdObjectUtils.getCompareLocalizedLabelFunction(intl));
}
}

0 comments on commit cd44d39

Please sign in to comment.