Skip to content

Commit

Permalink
modules: Literature: Sort by edition while rendering editions in Lite…
Browse files Browse the repository at this point in the history
…ratureRelations
  • Loading branch information
sakshamarora1 committed Feb 5, 2024
1 parent d3a17eb commit 14e3989
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/lib/modules/Literature/LiteratureRelations.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,21 @@ export default class LiteratureRelations extends Component {
const relations = _get(this.relations, 'edition', []);
if (!relations.length) return null;

const items = relations.map((rel) => {
const edition = rel.record_metadata.edition;
return (
edition && (
<Link key={rel.pid_value} to={this.getLinkTo(rel)}>
<LiteratureEdition edition={edition} />
</Link>
)
);
});
const items = relations
.sort(
(rel1, rel2) =>
rel1.record_metadata.edition - rel2.record_metadata.edition
)
.map((rel) => {
const edition = rel.record_metadata.edition;
return (
edition && (
<Link key={rel.pid_value} to={this.getLinkTo(rel)}>
<LiteratureEdition edition={edition} />
</Link>
)
);
});

return (
<List.Item>
Expand Down

0 comments on commit 14e3989

Please sign in to comment.