Skip to content

Commit 03655f6

Browse files
bactgoneall
authored andcommitted
Sort crossRef by order and url
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
1 parent 1f80a5c commit 03655f6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/main/java/org/spdx/storage/listedlicense/LicenseJson.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.util.ArrayList;
2121
import java.util.Collections;
22+
import java.util.Comparator;
2223
import java.util.HashMap;
2324
import java.util.HashSet;
2425
import java.util.List;
@@ -557,4 +558,14 @@ public List<PropertyDescriptor> getPropertyValueDescriptors() {
557558
});
558559
return retval;
559560
}
561+
562+
/**
563+
* Sort the crossRef list by order, with URL as a secondary sort key for
564+
* entries with no order set.
565+
*/
566+
public void sortCrossRef() {
567+
crossRef.sort(Comparator
568+
.comparingInt((CrossRefJson c) -> c.order != null ? c.order : Integer.MAX_VALUE)
569+
.thenComparing(c -> c.url != null ? c.url : ""));
570+
}
560571
}

0 commit comments

Comments
 (0)