File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ impl TryFrom<Work> for BibtexThothEntry {
123123
124124 let mut contributions = work. contributions ;
125125 // WorkQuery should already have retrieved these sorted by ordinal, but sort again for safety
126- contributions. sort_by ( |a, b | a. contribution_ordinal . cmp ( & b . contribution_ordinal ) ) ;
126+ contributions. sort_by_key ( |a| a. contribution_ordinal ) ;
127127 let ( author, editor) = extract_authors_and_editors ( contributions) ?;
128128
129129 let shorttitle = work. titles [ 0 ]
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ impl From<Work> for CsvThothRow {
110110 fn from ( work : Work ) -> Self {
111111 let mut subjects = work. subjects ;
112112 // WorkQuery should already have retrieved these sorted by ordinal, but sort again for safety
113- subjects. sort_by ( |a, b | a. subject_ordinal . cmp ( & b . subject_ordinal ) ) ;
113+ subjects. sort_by_key ( |a| a. subject_ordinal ) ;
114114 CsvThothRow {
115115 publisher : work. imprint . publisher . publisher_name ,
116116 imprint : work. imprint . imprint_name ,
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ impl TryFrom<Work> for KbartOclcRow {
120120 // but this is not guaranteed, so we select the highest-ranked contributor of the
121121 // appropriate contribution type who is listed as a "main" contributor.
122122 // WorkQuery should already have retrieved these sorted by ordinal, but sort again for safety
123- contributions. sort_by ( |a, b | a. contribution_ordinal . cmp ( & b . contribution_ordinal ) ) ;
123+ contributions. sort_by_key ( |a| a. contribution_ordinal ) ;
124124 for contribution in contributions {
125125 if contribution. main_contribution {
126126 if work. work_type == WorkType :: EDITED_BOOK {
Original file line number Diff line number Diff line change @@ -571,7 +571,7 @@ fn toc_field(relations: &[WorkRelations]) -> ThothResult<FieldRepr> {
571571 ) ) ;
572572 }
573573 // WorkQuery should already have retrieved these sorted by ordinal, but sort again for safety
574- chapters. sort_by ( |a, b | a. relation_ordinal . cmp ( & b . relation_ordinal ) ) ;
574+ chapters. sort_by_key ( |a| a. relation_ordinal ) ;
575575 let mut chapter_list = chapters. iter ( ) . peekable ( ) ;
576576 let mut toc_field: FieldRepr = FieldRepr :: from ( ( b"505" , "00" ) ) ;
577577 let mut separator = " --" ;
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ impl XmlElementBlock<DoiDepositCrossref> for Work {
138138
139139 let mut chapters = self . relations . clone ( ) ;
140140 // WorkQuery should already have retrieved these sorted by ordinal, but sort again for safety
141- chapters. sort_by ( |a, b | a. relation_ordinal . cmp ( & b . relation_ordinal ) ) ;
141+ chapters. sort_by_key ( |a| a. relation_ordinal ) ;
142142 for chapter in chapters
143143 . iter ( )
144144 . filter ( |r| r. relation_type == RelationType :: HAS_CHILD )
Original file line number Diff line number Diff line change @@ -296,9 +296,8 @@ impl XmlElementBlock<Onix3GoogleBooks> for Work {
296296 . any ( |c| c. contribution_type . eq ( & ContributionType :: AUTHOR ) )
297297 {
298298 // WorkQuery should already have retrieved these sorted by ordinal, but sort again for safety
299- contributions
300- . sort_by ( |a, b| a. contribution_ordinal . cmp ( & b. contribution_ordinal ) ) ;
301- contributions. sort_by ( |a, b| b. main_contribution . cmp ( & a. main_contribution ) ) ;
299+ contributions. sort_by_key ( |a| a. contribution_ordinal ) ;
300+ contributions. sort_by_key ( |b| std:: cmp:: Reverse ( b. main_contribution ) ) ;
302301 contributions[ 0 ] . contribution_type = ContributionType :: AUTHOR ;
303302 }
304303 for contribution in & contributions {
You can’t perform that action at this time.
0 commit comments